利用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 }
