将浏览器滚动条替换为自定义内容滚动条 [英] Replace Browser Scrollbar with Custom Content Scroller
问题描述
我正在使用 jQuery自定义内容滚动条,并正确安装了所有文件.但是,我想用这个插件代替我的默认浏览器滚动条,而我很难做到这一点.显然,我需要将其应用于整个HTML标记.
I'm using the jQuery custom content scroller on my site and have all the files installed correctly. However, I would like this plugin to replace my default browser scrollbar and I'm having a difficult time making that happen. Obviously, I would need to apply it to the overall HTML markup.
要将此插件添加到内容中,开发人员建议如下:
To add this plugin to content the developer suggests the following:
<script>
(function($){
$(window).load(function(){
$(".your-div-class-here").mCustomScrollbar();
});
})(jQuery);
</script>
到目前为止,要将其应用于浏览器滚动条,我已经尝试了下面的代码,但该代码无效:
So far, to apply it to the browser scrollbar, I've tried the code below and it hasn't worked:
<script>
$(document).ready(
function() {
$("html").mCustomScrollbar();
}
);
</script>
有人知道我做错了什么,或者如何使该代码在浏览器上工作?
Does anybody know what I'm doing incorrectly, or how I can make this code work on the browser?
推荐答案
您需要将其应用于body(而非html)标记:
You need to apply it to the body (not html) tag:
$("body").mCustomScrollbar();
从插件主页查看此演示: http://manos.malihu.gr/tuts/custom-scrollbar-plugin /full_page_demo.html
See this demo from plugin homepage: http://manos.malihu.gr/tuts/custom-scrollbar-plugin/full_page_demo.html
这篇关于将浏览器滚动条替换为自定义内容滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!