我已經在我的容器,這通常是身高超過所有這些div
S組合得到了一些div
小號垂直自動排列多個div。我希望他們平均分配,但不是作爲一個團體。下面的圖片應該解釋我想要做的事情。有什麼辦法來實現使用引導3這個簡單的方法是什麼?容器中(而不是作爲一組!)
2
A
回答
5
您可以做純CSS,但其實這是如此刻着容易Flexbox的。
.parent {
display: flex;
flex-direction: column;
justify-content: space-around;
}
.child {
flex: 1 1;
}
類似的東西應該工作。
2
這是一個完美的用例Flexbox的:
.flex-container {
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-justify-content: space-around;
-ms-flex-pack: distribute;
justify-content: space-around;
-webkit-align-content: center;
-ms-flex-line-pack: center;
align-content: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
}
.flex-item:nth-child(1) {
-webkit-order: 0;
-ms-flex-order: 0;
order: 0;
-webkit-flex: 0 0 auto;
-ms-flex: 0 0 auto;
flex: 0 0 auto;
-webkit-align-self: center;
-ms-flex-item-align: center;
align-self: center;
}
<div class="flex-container">
<div class="flex-item">Hello</div>
<div class="flex-item">Hello</div>
<div class="flex-item">Hello</div>
</div>
1
您可以使用display: felx
爲您的解決方案是這樣的:
.sides{ display:inline-block; margin: 0 10px }
ul {
display: flex;
flex-direction: column;
justify-content: space-between;
width: 150px;
padding: 10px;
margin: 0;
list-style: none;
background-color: grey;
}
#side1{ height: 100vh }
#side2{ height: 75vh }
#side3{ height: 50vh }
.box{
padding: 2px;
margin: 0 20%;
width: 60%;
box-sizing: border-box;
background-color: red;
color: white;
text-align: center;
}
<div class="sides">
<ul id="side1">
<li class="box">Line 1</li>
<li class="box">Line 2</li>
<li class="box">Line 3</li>
<li class="box">Line 4</li>
</ul>
</div><div class="sides">
<ul id="side2">
<li class="box">Line 1</li>
<li class="box">Line 2</li>
<li class="box">Line 3</li>
<li class="box">Line 4</li>
</ul>
</div><div class="sides">
<ul id="side3">
<li class="box">Line 1</li>
<li class="box">Line 2</li>
<li class="box">Line 3</li>
<li class="box">Line 4</li>
</ul>
</div>
相關問題
- 1. Draggable拖出內容而不是容器
- 2. 在容器的中心製作線條,而不是屏幕?
- 3. 通過迭代器而不是容器
- 4. SQL - 分組一些行作爲單行而不是其他
- 5. 作爲一個數組而不是DataMapper ORM集合對象
- 6. Emplace_back而不是push_back對stl容器?
- 7. 查看容器中,作爲一個
- 8. PHP:爲什麼我會得到「數組」而不是其內容
- 9. IE7不顯示SVG內容,而不是它打開內容作爲Office文檔
- 10. 只彙編作爲一個指針數組,而不是陣列中的陣列
- 11. 綁定到容器不是工作,而是結合對象的作品
- 12. STL算法採用整個容器而不是.begin(),end()作爲arg?
- 13. JQuery:追加字符串作爲內容,而不是html
- 14. Plone內容類型作爲文件夾而不是事件
- 15. 爲多個Docker容器使用域而不是端口
- 16. 爲什麼C++中的堆實現爲算法而不是容器?
- 17. 而不是觸發器不工作
- 18. 泊塢窗容器中運行的一臺計算機,而不是另一個
- 19. 爲什麼ajax在一臺服務器上工作而不是下一臺?
- 20. 在容器中指定身份驗證而不是在web.xml中
- 21. GET請求返回空數組而不是數組內容
- 22. 容器<ImplementerOfIInterface>不是容器<IInterface>。爲什麼不?
- 23. Ember 2,簡單的模式作爲組件,而不是控制器
- 24. formtastic - :串字段的值作爲數組,而不是發現-S
- 25. GoogleMap的一個片段,而不是作爲一個FragmentActivity
- 26. 平均值/ sd作爲一個值,而不是一個向量
- 27. UITableViewRowAnimation作爲一個塊(而不是一行)動畫
- 28. ng-content:transclude容器元素的內容,而不是元素本身?
- 29. Spark容器而不是它的身體外面隱藏內容
- 30. 獲取只有一個MySQL列作爲列表而不是元組