Forum Moderators: not2easy
Here's my CSS code (the background colors are for debugging):
* html ul li {height:1em; vertical-align:bottom;}
#sidenav {width:148px; margin-top:5px; margin-bottom:0px; padding-bottom:0px; padding-top:7px; padding-left:13px}
#sidenav ul li {font: 10px/18px Verdana, Arial, Helvetica, sans-serif; color:#fff; width:133px; text-indent:8px; background-color:#F16921; margin:0}
#sidenav ul li a {display: block; color:#3c3c3c; background-color:#dbdbdb;}
#sidenav ul li a:hover {background-color:#8c8c8c; text-decoration:none}
#sidenav ul .between {background-color:green; height:3px; line-height:0px} and here is the HTML;
<div id="sidenav">
<ul>
<li>Introduction</li>
<li class="between"></li>
<li><a href="#">Management</a></li>
<li class="between"></li>
<li><a href="#">Recent News</a></li>
<li class="between"></li>
<li><a href="#">Press</a></li>
<li class="between"></li>
<li><a href="#">Support</a></li>
<li class="between"></li>
<li><a href="#">Newsletter Signup</a></li>
<li class="between"></li>
<li><a href="#">Careers</a></li>
<li class="between"></li>
<li><a href="#">Partners</a></li>
<li class="between"></li>
<li><a href="#">Contact Us</a></li>
</ul>
</div> I've tried every solution I can find, but nothing seems to shrink the gaps. Help?!?
Thanks!
Placing your list entirely on a single line will fix. I believe that placing your linebreaks directly in front of the closing tag of each li tag will do it as well.
<ul><li>Introduction</li
><li class="between"></li
><li><a href="#">Management</a></li
><li class="between"></li
><li><a href="#">Recent News</a></li
><li class="between"></li
></ul>
#sidenav ul .between {background-color:green; height:3px; line-height:0px;font-size:1px}
This will solve the problem in IE6. Have not been able to test it on IE7.
As the font size was previously defined as 10px/18px, the .between li element was (wrongly) expanding to accomodate this font-size for the white space.
I did it that way so that I don't have to add an "active" class for every new page
well apart from the fact that doesn't really make sense, CSS can do this beautifully without scripting an "active" class
I'm thinking (feel free to shout!) you are not really using CSS for separation of design, you're imposing your design ideas on your HTML markup?
extra <li> items will be read by screen readers, focused by tab keys, and just might be picked up weirdly by RSS feeds!
sorry, but while I know it's fine in general just to get things working, make sure that the "fix" is the right one for you and your site, there are other ways to workaround this IE weakness, but it will depend on your requirements
You say I don't need to do it this way, but I only see 2 choices: my way or having an "active" class that would have the same style (padding especially) as the "li a" but with orange bg. Let me explain what is happening now a bit better:
the ul (and the page itself) has a white background
the "li"s have an orange background
the "li a"s have a grey background
there is a 3 px space between each li which is also white
-- if you delete the "between" lis and add padding to the li, you will have orange peek through
-- if you intead add padding to the "li a" you will get no peek though, but the li with an active state (no link, no a) will not be padded to match, so the list will be spaced inconsistently as you go to different pages (solution: add an active class with padding and orange bg)
does that make sense? if there's something I'm missing let me know!
: )
1. Removing the the .between li elements.
2. Adding a background-color to the ul element instead of the .between li's (in this case green)
3. Adding a 3px margin top and bottom to the remaining li elements.
You may have to add special classes for the first and list li elements to remove the top or bottom margin.
Thanks!
and here's the new CSS:
#sidenav {width:148px; margin-top:5px; margin-bottom:0px; padding-bottom:0px; padding-top:7px; padding-left:13px}
#sidenav ul li {display: block; font: 10px/18px Verdana, Arial, Helvetica, sans-serif; color:#fff; width:133px; text-indent:8px; background-color:#F16921; margin-top:3px; margin-bottom:3px}
#sidenav ul li a {display: block; color:#3c3c3c; background-color:#dbdbdb;}
#sidenav ul li a:hover {background-color:#8c8c8c; text-decoration:none} I was even able to delete this:
* html ul li {height:1em; vertical-align:bottom;} Thanks again!
^_^b