I'm experimenting with a horizontal navigation menu by adding a second line (brief description of link) of text inside span
tags, which are inside each li anchor.
It behaves as I expect in firefox & IE8, but not in chrome. In chrome,when I zoom out (ctrl -) the far right li drops down below in the ul, increasing the presented ul height.
I've noted these possible causes:
- I've used
span
on the text I want to be on the second line withdisplay:block
. I didn't know another way to bring it down without usingbr /
in the html. - I used
float:left
on the li's becausedisplay:inline
didn't work once I added thespan
mentioned above.
Here is an image of the result in chrome after using ctrl- to zoom out (green background added to see ul).
Here is my html:
<div id="navigation">
<ul>
<li><a href="#item1">first<span>first item desc</span></a></li>
<li><a href="#item2">second<span>second item desc</span></a></li>
<li><a href="#item3">third<span>third item desc</span></a></li>
<li><a href="#item4">fourth<span>fourth item desc</span></a></li>
<li><a href="#item5">fifth<span>fifth item desc</span></a></li>
<li><a href="#item6">sixth<span>sixth item desc</span></a></li>
</ul>
</div>
My css:
body{
font-size:16px;
min-width:984px;
*min-width:960px}
#navigation{
background:green;
width:984px;
*width:960px;
min-width:984px;
*min-width:960px;
margin:0 auto;
padding:0;
display:block;
float:left}
#navigation ul{
margin:0 auto;
width:100%;
padding:0;
list-style-type:none}
#navigation ul li{
float:left;
margin:0 1px;
padding:0}
#navigation ul li a{
text-decoration:none;
font:bold 20px/1em Verdana,Arial,Helvetica,Geneva,sans-serif;
width:162px;
*width:158px;
display:block;
background:#1b4260;
color:#cfcfcf;
margin:0;
padding:6px 0;
text-indent:6px}
#navigation ul li a:hover{
background:#2f5c81;
color:#fff}
#navigation a span{
display:block;
font:normal 11px Verdana,Arial,Helvetica,Geneva,sans-serif}
What am I doing improperly? Also, any advise to improve this menu's code overall?