White space on vertical menu IE7

2019-07-29 02:19发布

问题:

I have an expandable menu.

On IE7 I'm getting a white gap at the top and the bottom. On IE8 just at the top. I've tried different suggestions but nothing seems to help.

You can see the site in here: http://dffernandez.com/client_review_files/wap/

The problem is on the "infraestructure" button (The 2nd one)

Thank you in advance.

HTML

<!--Aside left nav-->
    <div id="secondary-nav">
      <ul>
        <li class="leaf-first"><a href="#"><img src="img/left-aside/sec-nav-arrow.png" width="21" height="21" class="sec-nav-arrow" alt="">airport &amp; location details</a></li>
        <li class="expand-top"></li> <!--Extra li so it can expand background-->
        <li class="leaf-expand"><a href="#">infraestructure</a>
          <!--Submenu-->
          <ul class="asidel-submenu">
            <li class="leaf-first"><a href="#">Current Tenants</a></li>
            <li class="leaf"><a href="#">Industry Especific Info</a></li>
            <li class="leaf"><a href="#">Aerospace</a></li>
            <li class="leaf"><a href="#">Unmanned Aerial Vehicles</a></li>
            <li class="leaf"><a href="#">Repair</a></li>
            <li class="leaf-las"><a href="#">Summary of Master Plan</a></li>
          </ul> <!--Submenu ends-->
        </li> <!--Expand-->
        <li class="expand-bottom"></li> <!--Extra li so it can expand background-->
        <li class="leaf"><a href="#"><img src="img/left-aside/sec-nav-arrow.png" width="21" height="21" class="sec-nav-arrow" alt="">communities</a></li>
        <li class="leaf"><a href="#"><img src="img/left-aside/sec-nav-arrow.png" width="21" height="21" class="sec-nav-arrow" alt="">newsroom</a></li>
        <li class="leaf-last"><a href="#"><img src="img/left-aside/sec-nav-arrow.png" width="21" height="21" class="sec-nav-arrow" alt="">location map</a></li>
      </ul>
    </div> <!--Aside left nav-->

CSS

/*secondary nav*/
#aside-left #secondary-nav li{
list-style: url(none) none;
margin-bottom: 13px;
}

#aside-left #secondary-nav li a {
height: 31px;
display: block;
background: url(../img/left-aside/sec-nav-back.png);
text-transform: uppercase;
text-decoration: none;
padding-top: 12px;
padding-left: 12px;
}

#aside-left #secondary-nav ul .leaf-expand a {
background: url(../img/left-aside/sec-nav-expand-back.png) repeat-y;
height: auto;
padding-top: 6px;
padding-bottom: 6px;
}

#aside-left #secondary-nav ul .leaf-expand img { /*controls the arrow position next to the expand. For changing the image go to js/script.js*/
display: block;
float: left;
margin-right: 6px;
padding-left: 12px;
margin-top: 3px;

}
#aside-left #secondary-nav ul .expand-top {
background: url(../img/left-aside/sec-nav-expand-back-top.png) no-repeat;
height: 7px;
margin-bottom: 0px;

}
#aside-left #secondary-nav ul .expand-bottom {
background: url(../img/left-aside/sec-nav-expand-back-bottom.png) no-repeat;
height: 6px;
margin-top: -13px;

}
#aside-left #secondary-nav .asidel-submenu {
padding-left: 39px;
padding-right: 12px;
padding-bottom: 9px;
background: url(../img/left-aside/sec-nav-expand-back.png) repeat-y;

} 
#aside-left #secondary-nav .asidel-submenu li {
list-style: disc inside;
margin-bottom: 3px;
color: #0073BC;

}
#aside-left #secondary-nav .asidel-submenu li a {
text-transform: none;
display: inline;
padding-left: 0px;

}
#aside-left #secondary-nav .sec-nav-arrow {
margin-right: 6px;
display: block;
float: left;
margin-top: -3px;

}

回答1:

I've come across this problem before, the fix is simple, yet somewhat odd. All explained fully here - http://www.456bereastreet.com/archive/200610/closing_the_gap_between_list_items_in_ie/

The gist of it, in IE7, is this:

li a {display:inline-block;}
li a {display:block;}

That's right, you have to say display: inline-block BEFORE you say display: block. Weird, huh? But it works!

And you can do it in all browsers too.

EDIT: My bad, I jumped to a conclusion about your post - here's a better answer for you:

The way you're doing it is a really crazy way to try and accomplish it. The "graphic" you're trying to preserve can be replicated in CSS by a simple border. Take a look at this fiddle:

http://jsfiddle.net/CC4gv/

Now you can get rid of the extra li's altogether.



回答2:

The important rules of styling list-based menus:

  • Reset your list ul, li {padding:0;margin:0}
  • Do not style the list elements (ul, li) for anything other than position, float or display
  • Use display:block and put all styling on the A-tag

This takes care of 99% of all list layout problems.

Also, UI elements should be CSS background images, not inline tags. This will help you maintain more control over the layout.

This is all explained in my tutorial: I Love Lists.