Stupid.Fat.Cat Stupid.Fat.Cat - 6 months ago 27
CSS Question

Scrollbar "jumps" to another location with scrollable container when checkbox is clicked

Here's my fiddle:

I have this class

overflow: auto;

and I have say a very long div with many elements:

<div class=scrollable>
<input type="checkbox" id="test0" />
<label for="test0">Red</label>
<input type="checkbox" id="test1" />
<label for="test1">Red</label>

When I click on an element say test51 my scrollbar jumps down to the element location as if it was not contained within the scrollable div. Any one has any idea why this is happening?


Turns out the answer is simple, simply add:

    position: relative;

I've also fixed your closing </div>'s in the jsfiddle (they were <div/> originally).