Reputation: 3168
I found a way to change the background color of a menu option upon hover. However, when you hover an option, it takes up some wide space that moves all the other options to the right, its sort of annoying, i want to maintain a consistent space, so if i hover, only the color should change, not the option moving to the right. Sort of the way facebook has its menu options.
Below is the code:
<div id="menu">
<a href="/hello" id="option">home</a>
<a href="/hello" id="option">profile</a>
<a href="/hello" id="option">account</a>
<a href="/hello" id="option">settings</a>
<a href="/hello" id="option">extra</a>
<a href="/hello" id="option">logout</a>
</div>
CSS:
div#menu {
margin-left: 630px;
margin-top:-20px;
}
option {
margin-left: 20px;
}
#option:hover{
background: #3F2327;
padding: 10px;
}
Upvotes: 0
Views: 466
Reputation: 943564
Remove padding: 10px;
Space around an element takes up space, so if you don't want space, don't add it. If you want it all the time, add it all the time and not just for :hover
Also, unrelated to your problem, but just good practises:
Upvotes: 8
Reputation: 6981
1) You are missing a # on "option"
2) Why are you padding on hover? That will cause a movement when you hover above it.
Upvotes: 2