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?
Scrollbar Selectors For webkit browsers, you can use the following pseudo elements to customize the browser's scrollbar: ::-webkit-scrollbar the scrollbar. ::-webkit-scrollbar-button the buttons on the scrollbar (arrows pointing upwards and downwards). ::-webkit-scrollbar-thumb the draggable scrolling handle.
In September 2018, W3C CSS Scrollbars defined specifications for customizing the appearance of scrollbars with CSS. As of 2020, 96% of internet users are running browsers that support CSS scrollbar styling. However, you will need to write two sets of CSS rules to cover Blink and WebKit and also Firefox browsers.
To get Custom Scrollbars, open the extension on the Chrome Web Store within Google Chrome. Click the + Add to Chrome button on that webpage. Select the Add extensions option to confirm. If you don't see a Custom Scrollbars button on the URL toolbar after installing it, click the Extensions option.
Note: ::-webkit-scrollbar is only available in Blink- and WebKit-based browsers (e.g., Chrome, Edge, Opera, Safari, all browsers on iOS, and others). A standardized method of styling scrollbars is available with scrollbar-color and scrollbar-width .
You need to apply it to the body (not html) tag:
$("body").mCustomScrollbar();
See this demo from plugin homepage: http://manos.malihu.gr/tuts/custom-scrollbar-plugin/full_page_demo.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With