利用ul的text-align:center属性:
设置ul的display:table,text-align:center。
注:1.这里必须用display:table属性。
2.不可以设置ul的宽。
下面是一段代码:
1 #nav { 2 height: 30px; 3 position: relative; 4 bottom: 20px; 5 display: table; 6 margin: 0 auto; 7 text-align: center; 8 } 9 #nav li{ 10 width: 5px; 11 height: 5px; 12 border-radius: 50%; 13 margin-left: 3px; 14 border: 3px solid #999999; 15 float: left; 16 17 }