参考博客:http://www.qianxingzhem.com/post-1602.html

接着上篇,另一个使用的例子,使用js来初始化滚动条,并且div中的内容可变化。需要调用相应的方法,

代码:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>jquery版的自定义滚动条</title>
<link rel="stylesheet" type="text/css" href="bootstrap/bootstrap.min.css">
<!--<link rel="stylesheet" type="text/css" href="jquery/jquery.mCustomScrollbar.min.css">-->
<link rel="stylesheet" type="text/css" href="jquery/jquery.mCustomScrollbar.css">
<style type="text/css">
.content{
width: 500px;
margin: 0 auto;
border: 1px solid #ccc;
padding: 10px 0 10px 10px;
height: 300px;
overflow: auto;
display: none;
}
.toolbar{
width: 500px;
margin: 0 auto;
margin-top: 20px;
}
/** 覆盖滚动条样式 */
.mCS-dark-3.mCSB_scrollTools .mCSB_dragger .mCSB_dragger_bar {
background-color: #333;
}
.mCS-dark-3.mCSB_scrollTools .mCSB_dragger.mCSB_dragger_onDrag .mCSB_dragger_bar{
background-color: #333;
background-color: rgba(102,102,102,0.9);
}
.mCSB_inside > .mCSB_container {
margin-right: 20px;
}
</style>
</head> <body> <div class="container">
<div class="row">
<h3 class="text-center">详情描述</h3>
<!--<div class="content mCustomScrollbar" data-mcs-theme="dark"></div>-->
<div class="content"> </div>
<div class="toolbar">
<button class="btn btn-default" id="btn_show">点击显示内容</button>
<button class="btn btn-default" id="btn_append">点击加载内容</button>
<button class="btn btn-default" id="btn_clear">点击清除内容</button>
</div> </div>
</div> </body>
<script src="jquery/jquery.min.js"></script>
<script src="bootstrap/bootstrap.min.js"></script>
<script src="jquery/jquery.mCustomScrollbar.concat.min.js"></script>
<script type="text/javascript">
$(function(){
$(".content").mCustomScrollbar({
theme:"dark-3",
scrollbarPosition: 'inside', //滚动条在内部还是外部
scrollInertia:100, //滚动延迟, 0禁用
//autoDraggerLength:true, //滚动条长度是否随内容多少而变
autoHideScrollbar:false, //自动隐藏滚动条
horizontalScroll:false, //是否创建水平滚动条
scrollButtons:{
enable: true //是否使用上下滚动按钮
}
}); $('#btn_clear').click(function(){
$('.content .mCSB_container').text('');
});
$('#btn_show').click(function(){
$('.content').show();
});
$('#btn_append').click(function(){
var string = '所谓的甩头。就是虚实举球马上停加碎步。就是篮筐反方向键。↓W或者下DW。马上停。然后调整人物方向带着这几点疑问看视频吧:1.C防两个人的时候是怎么防的?2.怎么应对女PF的钟头?3.被吸到的时候是怎么保证不倒的?还是就不让敌人吸到你?4.篮板是怎么抢的? 等分? 直接秒?';
for(var i=0; i<3;i++){
string += string;
}
$('.content .mCSB_container').append(string);
$('.content').mCustomScrollbar('update');
})
});
</script>
</html>

页面效果:

使用jquery.mCustomScrollbar自定义滚动条(2)的更多相关文章

  1. 使用jquery.mCustomScrollbar自定义滚动条(4)live使用,向未来元素添加滚动条,不实用,了解一下

    .div_box元素是本来没有的,在滚动条初始化的时候方法是加在$('.content .div_box').mCustomScrollbar()上面,参数live:on; 点击按钮的时候,进行con ...

  2. 使用jquery.mCustomScrollbar自定义滚动条(3)callback onCreate

    碰到了一个问题,想简洁,所以在页面上使用 <div class="div_box mCustomScrollbar" data-mcs-theme="dark-3& ...

  3. 使用jquery.mCustomScrollbar自定义滚动条(1)

    参考博客:https://blog.csdn.net/cdnight/article/details/41351505 api网址:http://manos.malihu.gr/jquery-cust ...

  4. 基于jQuery的自定义滚动条

    在线演示 本地下载

  5. jQuery自定义滚动条样式插件mCustomScrollbar

    如果你构建一个很有特色和创意的网页,那么肯定希望定义网页中的滚动条样式,这方面的 jQuery 插件比较不错的,有两个:jScrollPane 和 mCustomScrollbar. 关于 jScro ...

  6. 自定义滚动条 - mCustomScrollbar

    项目中需要使用自定义滚动条,但是试用了很多都功能不够全,今天发现一个比较全而且用法很简单的 -- mCustomScrollbar http://manos.malihu.gr/jquery-cust ...

  7. 自定义滚动条mCustomScrollbar

    mCustomScrollbar 是个基于 jQuery UI 的自定义滚动条插件,它可以让你灵活的通过 CSS 定义网页的滚动条,并且垂直和水平两个方向的滚动条都可以定义,它通过 Brandon A ...

  8. 滚动条mCustomScrollbar自定义

    mCustomScrollbar 是个基于 jQuery UI 的自定义滚动条插件,它可以让你灵活的通过 CSS 定义网页的滚动条,并且垂直和水平两个方向的滚动条都可以定义,它通过 Brandon A ...

  9. jquery自定义滚动条 鼠标移入或滚轮时显示 鼠标离开或悬停超时时隐藏

    一.需求: 我需要做一个多媒体播放页面,左侧为播放列表,右侧为播放器.为了避免系统滚动条把列表和播放器隔断开,左侧列表的滚动条需要自定义,并且滚动停止和鼠标离开时要隐藏掉. 二.他山之石: 案例来自h ...

随机推荐

  1. day021python 正则表达式

    正则表达式是由普通字符和元字符组成, 普通字符包含大小写字母, 数字. 在匹配普通字符 的时候我们直接写就可以了. 比如"abc" 匹配的就是"abc". 元字 ...

  2. PTA——支票面额

    PTA 7-38 支票面额 #include<stdio.h> int main() { int n,f,y; ; scanf("%d",&n); ; flag ...

  3. 如何运行简单的scrapy

    1.建scrapy工程 scrapy startproject python123demo 2.在工程中写一个爬虫文件 cd python123demo scrapy genspider demo p ...

  4. C++学习(十七)(C语言部分)之 指针

    复习 数组定义格式 类型 数组名[数组大小]数组名+下标 int arr[2][3]={{1,2,3},{4,5,6}}; int arr[][3]={1,2,3,4,5,6};//二维数组定义的时候 ...

  5. hdu2204 Eddy's爱好 打表+容斥原理

    Ignatius 喜欢收集蝴蝶标本和邮票,但是Eddy的爱好很特别,他对数字比较感兴趣,他曾经一度沉迷于素数,而现在他对于一些新的特殊数比较有兴趣.这些特殊数是这样的:这些数都能表示成M^K,M和K是 ...

  6. hdu1686 Oulipo KMP/AC自动机

    The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e ...

  7. 【mybatis源码学习】利用maven插件自动生成mybatis代码

    [一]在要生成代码的项目模块的pom.xml文件中添加maven插件 <!--mybatis代码生成器--> <plugin> <groupId>org.mybat ...

  8. mysql中 where in 用法详解

    这里分两种情况来介绍 1.in 后面是记录集,如: select  *  from  table  where   uname  in(select  uname  from  user); 2.in ...

  9. java 实现websocket的三种方式

    Java中实现websocket常见有以下三种方式: 使用tomcat的websocket实现,需要tomcat 7.x,JEE7的支持. 使用spring的websocket,spring与webs ...

  10. 实例对象与 new 命令

    引用:https://wangdoc.com/javascript/oop/new.html JavaScript 语言的对象体系,不是基于"类"的,而是基于构造函数(constr ...