dibs_ab
dibs_ab

Reputation: 723

Width of hover element should increase the highlight box size and retain the dropdown

I have three questions in CSS. Being a developer not a pro in design but need to solve this issue. I have a navigation bar which looks something like this:

<nav id="primary">
   <ul>
      <li><a href="#">Home</a></li>
      <li><a href="#">About</a>
          <ul>
            <li><a href="#" class="outer"><span class="arrow">></span>Item1</a></li>
            <li><a href="#" class="outer"><span class="arrow">></span>Item2</a></li>
          </ul>
      </li>
      <li><a href="#">Contact</a></li>
   </ul>
</nav>

My embedded-CSS looks like

#primary ul li ul
{
display: none;
}
#primary li:hover >ul
{
  display: block;
  position: absolute;
  background: #bfe9f7;
  -webkit-border-shadow :0 1px 1px rgba(0,0,0,.2);
  -moz-box-shadow:0 1px 1px rgba(0,0,0,.2);
  box-shadow: 0 1px 1px rgba(0,0,0,0.2);
}
#primary ul li
{
  display: inline;
}
#primary li:hover
{
  position: relative;
}
#primary li a:hover
{
  background: #8ac142;
}
#primary li:hover ul 
{
  left: 0px;
  top: 30px;
  padding: 3px;
  width: 180px;
}
.arrow
{
  color: #009aca;
}
#primary ul li ul li a.outer 
{
  color: #3d3d3d;
  -webkit-box-shadow: 0px 4px 2px -2px #4cbadd;
  -moz-box-shadow: 0px 4px 2px -2px #4cbadd;
  box-shadow: 0px 4px 2px -2px #4cbadd;
}

Now when I hover over 'About' the drop-down is displayed but, 1. It disappears if I move even a bit, making me unable to click 'Items' 2. The hover state of about gives a background colour green I want to increase the area of hover. 3. I have mentioned #primary li:hover >ul what does the '>' actually does?

Upvotes: 0

Views: 3134

Answers (1)

Justin
Justin

Reputation: 27331

  1. Remove the css for top and left for #primary li:hover ul

    #primary li:hover ul 
    {
      padding:10px;
      width: 180px;
    }
    
  2. Increase your padding.

    #primary ul li ul li a.outer 
    {
       padding:5px;
    }​
    

    Example: http://jsfiddle.net/j2NsZ/3/

3.'>' is a selector for the children elements (more info)

Upvotes: 2

Related Questions