How to control div on hover:?

Posted by AAA on Stack Overflow See other posts from Stack Overflow or by AAA
Published on 2011-01-15T00:39:01Z Indexed on 2011/01/15 0:53 UTC
Read the original article Hit count: 135

Filed under:
|
|
|
|

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;
  }

© Stack Overflow or respective owner

Related posts about html

Related posts about css