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

Time:08-28

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 >
contents
</div>

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

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

CodePudding user response:

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

  • Related