如何制作100%水平的跨浏览器菜单HTML / CSS?
1.保持干净的HTML,使用li列表 2.无图像/ JavaScript,无表格,符合W3C标准
下面是一个“无效”示例:
1.保持干净的HTML,使用li列表 2.无图像/ JavaScript,无表格,符合W3C标准
下面是一个“无效”示例:
![100% horizontal cross-browser menu HTML/CSS example](https://lh4.ggpht.com/_aamJGQI2gQ0/TDt-ZwIJMTI/AAAAAAAAAO0/6J_Yni4FQmI/nav.gif)
/*CSS doesn't make `block` right/left space between `li` items (see attached image)*/
#nav{
text-align:justify;
}
#nav li{ /*border:1px solid #000; margin-right:1px; margin-left:1px;*/
display:inline-block; white-space:nowrap;
}
#nav li#span{ /*hack to make 100% horizontal*/
display:inline-block; width:100%; height:1px;
}
*html #nav li,*html #nav li#span,*+html #nav li,*+html #nav li#span{ /*IE6/7 hacks tah are not working*/
display:inline;
}
并且:
<div id="nav">
<ul>
<li>Home <!--unfortunately it doesn't work without space after each list,
need for some solution--></li>
<li>Services </li><!--don't want to add style for each list separated-->
<li>Portfolio </li>
<li>Clients </li>
<li>Articles </li>
<li>Contact Us </li>
<li id="span"></li><!--don't like to add any extra tag (like this),
but other way it doesn't work,
need for some solution-->
</ul>
</div>