Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to Show scrollbar while mouse hover the container without affecting alignment

I want to display scrollbar while the mouse hover the container, if the contents inside the container overflows the container.

The below code works good in chrome but doesn’t work in firefox, because it doesn’t suppport overlay property.

<style type="text/css">
.container {
overflow:hidden;
}
.container:hover {
overflow:overlay;
}
</style>

<div class="container">
contents
</div>

I tried using overflow:auto on hover but it changes the alignment of text inside the container while mouse hovers.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Is there any way to achive my need in all browsers?

>Solution :

Add scrollbar-gutter:stable to .container and this should do the trick. More info here and here.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading