Another CSS problem for the forum, and this one kind of made me sick (literally) just watching my screen bounce all over the place!
The situation is this: I have a list of items that upon mouse over, I would like to have the list item be highlighted by adding some space (margin) between that li and the li above and below it, and then giving it some font weight: bold goodness, and maybe even a boost in font size. To achieve this, I am using the li:hover selector, and I’m getting good results.
The problem is this: everything below the li jiggles uncontrollably as you move the mouse up and down the list because it is being pushed or pulled by the new margin! Now, this isn’t so bad if it is just the list items below that are jiggling, that is understandable. What makes you cross eyed is any divs or paragraphs below the list that keep bouncing up and down.
At first, I thought I would just not be able to use this technique, but then I noticed that when you have two columns of lists that behave this way, the shorter column doesn’t jiggle anything below it, presumably because it has space to move. So then I thought, ok, I could add some kind of buffer element to absorb the jiggle, but all elements just push all the elements down.
I’m beginning to suspect I’m going to have to mess with the height of the container, problem is that the list is dynamic, so I don’t know what the height will be! Does anyone have the cure for my jiggles?
Here is some example code, first the CSS:
#wrapper {
width: 600px;
margin: auto;
border: 1px solid #000;
}
#col1 {
widht: 300px;
float: left;
}
#col2 {
width: 300px;
float: right;
}
li:hover {
font-weight: bold;
margin-top: 5px;
margin-bottom: 5px;
}
.clearBoth {
clear: both;
}
#footer {
text-align: center;
}
Next the HTML:
<div id="wrapper">
<div id="col1">
<ul>
<li>one jiggle</li>
<li>two jiggle</li>
<li>three jiggle</li>
<li>four</li>
<li>five jiggle...</li>
</ul>
</div>
<div id="col2">
<ul>
<li>one</li>
<li>two</li>
<li>no jiggle!</li>
</ul>
</div>
<div class="clearBoth"> </div>
<div id="footer">
<p>I'm getting sick from all the jiggles!</p>
</div>
</div>
Try it out, and you’ll see that poor bottom paragraph bouncing all over the place when you scroll over the first column, but not when you scroll over the second!