welc0meToTheMachine welc0meToTheMachine - 9 months ago 46
CSS Question

How to effectively make div scrollable on hover only, and have it stay in that position when not hovering?

I know I can make a div scrollable on hover by using a fixed height, and by using

normally, and
overflow-y: scroll
on hover.

However, my div is a list of 30 items, and height 50px. If I hover, and scroll down to the 25th item, then move cursor out, the div changes to show the first few items (i.e. top of the div), NOT where I was previously just before moving cursor out.

How can I keep div in same position when I've hovered out?


Working here:


Your CSS just needed to be changed to:

#listOfTags{ overflow:hidden; height: 50px; } #listOfTags:hover{overflow-y: scroll;}