我有以下HTML,其中浮左和浮右類做到這一點:如何讓我的包裝按鈕的DIV使用一些垂直空間?
<div class="block-footer">
<button class="medium float-left">A</button>
<button class="medium float-left">A</button>
<button class="medium float-left">A</button>
<button class="medium float-right">A</button>
<button class="medium float-right">A</button>
</div>
這工作,但我的div似乎沒有佔據的垂直空間,這對接下來的一個問題。當我這樣做:
<div class="block-footer">
<button class="medium float-left">A</button>
<button class="medium float-left">A</button>
<button class="medium float-left">A</button>
<button class="medium float-right">A</button>
<button class="medium">A</button>
</div>
然後DIV佔據空間。
那麼我怎樣才能讓一些按鈕浮動到左側,一些到右側,仍然有DIV使用一些垂直空間?
清除你的FLOATS –
看看http://nicolasgallagher.com/micro-clearfix-hack/你可以嘗試通過你自己的'clearfix'類來使用浮動按鈕。像這樣:'.clearfix:before,.clearfix:after {display:table;內容:「」; } .clearfix:在{clear:both; }'但是我還沒有看到'button'元素是如何工作的,但是試過了......它也取決於你需要支持的瀏覽器,或者你可以添加一個clearfix'div'作爲'block- footer'。同樣,你也知道,如果你漂浮的「塊腳」,也使得它環繞其漂浮的孩子。 – Pricey