I have a menu that uses Bootstrap offcanvas but I wanted to style its scroll bar in the style of Facebook chat.
I have a menu that uses Bootstrap offcanvas but I wanted to style its scroll bar in the style of Facebook chat.
The problem is that custom scrolling is not something that is in the specification, so there is no need for browsers to implement this feature. Some include this feature and allows the scroll to be customized, I repeat: Some.
In addition, what you need to do is scroll with CSS and Javascript. This is the only way to have a cross browser functionality, which is why there are several plugins that handle this feature.
$(function() {
$('div').mCustomScrollbar();
});
div {
height: 100px;
width: 50%
}
<!-- dependência do JQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><!--Plugin--><linkhref="https://cdnjs.cloudflare.com/ajax/libs/malihu-custom-scrollbar-plugin/3.1.0/jquery.mCustomScrollbar.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/malihu-custom-scrollbar-plugin/3.1.0/jquery.mCustomScrollbar.min.js"></script><div><p>Loremipsumdolorsitamet,consecteturadipiscingelit.Vivamusfacilisisrisusatorcifringilla,etegestasturpishendrerit.Nullavelleourna.Donecblanditfermentumorciinimperdiet.Aliquameratvolutpat.Donecsedelitmi.Nunceunullanulla.</p></div>
$(function() {
$('div').niceScroll();
});
div {
height: 100px;
width: 50%
}
<!-- dependência o JQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><!--Plugin--><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jquery.nicescroll/3.6.0/jquery.nicescroll.min.js"></script>
<div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus facilisis risus at orci fringilla, et egestas turpis hendrerit. Nulla vel leo urna. Donec blandit fermentum orci in imperdiet. Aliquam erat volutpat. Donec sed elit mi. Nunc eu nulla nulla.
</p>
</div>
In addition to the above look you can customize it, so linkei the projects for you to read the documentation on how to do this. If neither of you meets your needs, there are several more.
Your question is pretty general, as it does not come with a minimal, complete, and verifiable example . So assuming you want to know what elements (in this case, pseudo-elements) you should style, they are
::-webkit-scrollbar
::-webkit-scrollbar-button
::-webkit-scrollbar-track
::-webkit-scrollbar-track-piece
::-webkit-scrollbar-thumb
::-webkit-scrollbar-corner
::-webkit-resizer
What I know, only the browsers that have webkit behind will allow you to make this stylization. In the CSS-Tricks has an article about it (that's where I took the elements). This discussion in Gringo OS brings you all the details of doing this stylization cross -browser.