2012-01-23 35 views
0

我有一個列表,我想添加一個邊框到它。但是當我這樣做時:我不能把邊框放在我的ul

<ul style="list-style-type: none;padding:3px;margin:3px; "> 
    <li style="border:1px dashed; width: 60px; float:left; height: 70px; margin:6px;"></li> 
    <li style="border:1px dashed; width: 60px; float:left; height: 70px; margin:6px;"></li> 
    <li style="border:1px dashed; width: 60px; float:left; height: 70px; margin:6px;"></li> 
</ul> 

li元素看起來在ul的邊界之外。 這段代碼有什麼問題,或者我只是使用了錯誤的技術?

回答

2

嘗試增加overflow:auto;到列表中的CSS:

<ul style="list-style-type: none;padding:3px;margin:3px; overflow:auto; "> 
+0

謝謝!它的工作:D –

+0

完成,對不起,我是一個在stackoverflow noob。 –

0

李的出現在境外的原因是因爲它們被設置爲浮動:左;並且float將它們包含元素的正常流程之外的元素。另一個解決方案是刪除float:每個li留下CSS,並以不同的方式設置它(不確定頁面的其餘部分是如何設置的)。

相關問題