如果你想在你的代码中继续使用你的浮动 LI,你可以使用这个:
JSFiddle:https ://jsfiddle.net/Lvujttw3/
<style>
.wrapper {
width: 100%;
background-color:#80B5EB;
text-align: center;
}
.intWrapper {
display: inline-block;
}
.mainMenu {
padding: 0;
min-height: 40px;
margin:auto;
}
ul {
list-style-type: none;
}
ul li {
float: left;
font-size: 15px;
line-height: 40px;
}
ul li A {
display: block;
color: white;
font-weight: bold;
font-family: Arial;
text-decoration: none;
min-height: 40px;
padding: 0 36px;
}
</style>
<div class="wrapper">
<div class="intWrapper">
<ul class="mainMenu">
<li><a href="one.htm" style='background-color:red'>ITEM ONE</a>
</li><li><a href="two.htm">ITEM TWO</a>
</li><li><a href="three.htm" style='background-color:red'>ITEM THREE</a>
</li>
</ul></div>
</div>
</div>