Reputation: 181
Here is my website. When you hover on Problem and move away, the div below it gets pushed up and down. Same happens for Solution. Any idea or tips how to prevent it from moving?
I think it is moving due to the changed font size and the underline, but I am not sure what I can do.
Upvotes: 2
Views: 3277
Reputation: 79
On hover, you enlarge the text, and thus the container. This pushes the rest of the content down.
3 solutions:
Use transform: scale(1.2);
to enlarge the text. This doesn't affect the flow of the document. Add this to your element:hover
. Remember to add browser prefixes. Read more here
Example:
#switcher li:hover {
transform: scale(1.2);
}
Add a height
to your navigation. This locks the container height.
Add position: absolute
on either the navigation or the content. This removes them from the document flow, so won't affect each other.
Upvotes: 1
Reputation: 1118
Set CSS line-height
to fix the height for text in <h3>
tags
Upvotes: 0
Reputation: 10786
this seems to fix it for me:
#switcher {
display: inline-block;
margin: 0;
overflow: hidden;
max-height: 30px;
}
basically I'm telling the container to not expand more than 30px in height.
Upvotes: 0