[英]How do I get the divs to float next to, and below each other
我有很多包含文本的div,我希望它們彼此相鄰並彼此下方對齊。
(我讀過一些東西,我應該為此做一個父母div,並給父母一個相對位置,給孩子一個絕對位置,但這對我不起作用)
但這是行不通的。
的HTML
<div class="block">
<!--<div class="blockboxgrid">-->
<div class="blockbox">
<h2>Title</h2>
<p>
Text
</p>
</div>
<!--</div>-->
</div>
的CSS
/*.blockboxgrid{
position:relative; <<< I saw this example while googling, to make the area where the box is in relative, and the box itself absolute. But this didn't work for me either.
}*/
.blockbox {
/*position:absolute;*/
background-color:#fff;
border-radius: 4px;
border:8px solid #ff6b6b;
display: block;
float: left;
margin: 10px;
width: 330px;
color:#000;
transition: all 0.5s ease;
}
http://jsfiddle.net/zqrjLz9d/1/到這里了。
.block { width:100%; height:auto; display: inline-block; float:left; }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.