My CSS is:
#menu {
background-color: #a40a0a;
width: 830px;
height: 36px;
position: relative;
top: 39px;
left: 172px;
}
#menu >ul {
list-style-type: none;
}
#menu ul li {
font-family: Arial, Helvatica, Verdana;
}
#menu ul li >a {
display: block;
float: left;
text-decoration: none;
color: #ffffff;
line-height: 36px;
width: 166px;
text-align: center;
}
#menu ul li >a:hover {
background-color: #d74343;
border-bottom: 2px solid #bc1515;
line-height: 34px;
}
#menu ul li >a:active {
background-color: #a40a0a;
}
This menu does not look right ie7 and belows. If this is wrong, please tell me the right, thanks.
http://jsfiddle.net/a4Qe3/ here is the link
You need to put
floaton theliinstead of thea. This is bacause the li will block each time.Here is the the updated code:
CSS
Demo
Edit 1
We put the
floaton theliinstead of theabecause eachais wrapped in aliwhich hasdisplay: block;applied to each. If you think of the DOM structure, if you float theatags you are floating items next to each other, that are not in the same scope. They are not DOM siblings. Their parents are. So you are just leaving their parents hanging around. Now in IE7, if you float after a blocking element, that floated item will be pushed down, as was happening in your case. So what we should do is float theliitems.Here is a demo where the
atags are floated, and I have put a border around thelitags to show what is going on. Check it in IE7.