In one of the comments on this question I was asked to use the scrollbar malihu (jQuery plugin). It was not possible to ask a question in the comments on the developer page - the server is buggy there when sending a comment.
I did not manage to make this plugin work like this:
<head> ... <!--css--> <link rel="stylesheet" href="style/jquery.mCustomScrollbar.min.css"> <!--js--> <!--<script src="js/jquery-3.0.0.min.js"></script>--> <script src="js/jquery-1.11.0.min.js"></script> <script src="js/jquery.mCustomScrollbar.concat.min.js"></script> <script> (function($){ $(window).on("load",function(){ $("body").mCustomScrollbar({ theme:"minimal" }); }); })(jQuery); </script> </head>
I checked all the ways - everything is fine; connection with all files there. The script before closing </head>
also works. I looked through the browser HTML code after rendering: new elements have been added. However, the browser still shows the standard scrollbar. Did I miss something?
Update
I checked the solution of user Dmitry on one of my projects and it worked. Here's what the working code looks like: the plugin assigns <body>
its own class, "stuffs" the contents of the site before rendering, adds one more to the first <div>
:
But on my other site the plugin worked incorrectly. As you can see in the figure below, the <body>
class is assigned, and <div>
s are not added:
What can it do? I can assume such options:
- I have an adaptive layout, and the html-code is generated both when the page is loaded (
onload
), and when the window width is changed (onresize
). Each time the contents are cleared and a new one is added. I described my code in more detail in this question (I will not duplicate it). I tried to embed the srollbar script into my code, but to no avail. - But maybe the case in the
wrapper
block, which also wraps the entire contents of the site? I can not even say why I suggested this, because I do not know the details of the technical implementation of the malihu scrollbar.