我有一個三欄佈局非常有效:中心科3列響應CSS佈局無法適應
http://jsfiddle.net/nicorellius/YNyHW/7/
我的目標是預先存在的模塊化單元添加到中心div
,類別爲two-inner
。標記如下:
<html>
<head></head>
<body>
<div>
<div class="container">
<div class="one">
<div class="one-inner"></div>
</div>
<div class="two">
<div class="two-inner"></div>
</div>
<div class="three">
<div class="three-inner"></div>
</div>
</div>
</div>
</body>
</html>
該CSS可以在fiddle中看到。部分模塊化單元實際上是由一些PHP構建而成的,其中來自數據庫的一些數據被提取並顯示。我有一些陣列可用於模擬6個條目的測試,併爲模塊化單元提供2寬3高的盒子佈局。我的問題是,當我把這個單元添加到上面的佈局中時,我得到了類似下面的測試站點。
爲模塊化單元標記是像這樣:
<section class="unit">
<section class="buttons margin-top-2em">
<div class="button-fixed-width">
<button type="button" class="<bootstrap-button>">button 1</button>
</div>
<div class="button-fixed-width">
<button type="button" class="<bootstrap-button>">button 2</button>
</div>
<div class="button-fixed-width">
<button type="button" class="<bootstrap-button>">button 3</button>
</div>
</section>
<div class="row">
<?php // loop through some arrays to get module unit ?>
</div>
</section>
我已經嘗試了各種調整,試圖得到它,但也不是使外類one
的高度的唯一的事情, two
和three
接近零。
雖然我試過改變高度和其他位以使它適合,但我仍然無法弄清楚爲什麼中心div
不會升高。我錯過了什麼?
unit
類的CSS處於小提琴中。就它自己而言,它工作正常,並且我有一些斷點將其摺疊到一個列中。我只是不能獲得通過這部分...
編輯
試圖從@ kozlovski5一些想法後,我能夠得到div
上下移動,因爲我需要。但有一件事情讓我感到不安。我不太熟悉display: table
,display: table-cell
佈局,所以我確定我錯過了一些東西。例如,當我向相關的div
添加文本時,無論是one
,two
還是three
類,或內部類,@ kozlovski5推薦的調整都會消失。所以換句話說,如果我不使用top: -37.5em;
,只是用文本填充div
,那麼一切似乎都應該如此。這是當我嘗試使用邊框部分對佈局進行建模時,我得到了奇怪的行爲。
我結束了去浮標代替。參見上面的測試網站進行最終的測試
嘗試刪除類<引導按鈕> – 2013-11-02 20:08:54
我補充說,這樣你就知道它是什麼它。 ..這真的是一組按鈕類,使按鈕看起來像它一樣:'btn btn-primary btn-lg btn-block'等... – nicorellius