這段代碼是否使用了我想要做的最佳實踐?基本上我想要四個div塊以100%填充空間(每個div塊將是25%)。4個塊在每塊中有2個div的塊
然後在每個DIV塊,我想有左邊和文字右側的圖像(與20像素的空間圖像和文本之間)
我如何找出的百分比文本?由於我的圖像百分比爲33%,而20倍的保證金爲右。
http://jsfiddle.net/UMf3k/137/
<div id="wrapper-resources">
<div id="resources_row">
<div class="resources_cell1">
<div class="resources_lt">
<img src="http://icons.iconarchive.com/icons/aha-soft/food/256/apple-icon.png" width="76" height="76" />
</div>
<div class="resources_rt">
<p><strong>Webinar</strong>
Capital Projects: Hidden Gems In The World</p>
</div>
</div>
<div class="resources_cell2">
<div class="resources_lt">
<img src="http://www.purelynaturalskin.co.uk/wp-content/uploads/2011/09/Sweet-Orange-Oil.jpg" width="76" height="76" />
</div>
<div class="resources_rt">
<p><strong>Article</strong>
Capital Projects: Hidden Gems In The World</p>
</div>
</div>
<div class="resources_cell3">
<div class="resources_lt">
<img src="http://images.wikia.com/uncyclopedia/images/archive/d/d4/20080204233721!Pear.jpg" width="76" height="76" />
</div>
<div class="resources_rt">
<p><strong>Blog</strong>
Capital Projects: Hidden Gems In The World</p>
</div>
</div>
<div class="resources_cell4">
<div class="resources_lt">
<img src="http://www.whataboutwatermelon.com/wp-content/uploads/2009/06/watermelon_simple.jpg" width="76" height="76" />
</div>
<div class="resources_rt">
<p><strong>News</strong><br>
Capital Projects: Hidden Gems In The World</p>
</div>
</div>
</div>
</div>
#wrapper-resources {
position:relative;
width:100%;
border: none;
margin: 50px 0 0 0;
}
#resources_row {
height:100%;
white-space:nowrap;
}
.resources_cell1, .resources_cell2, .resources_cell3, .resources_cell4 {
height:100%;
width:25%;
display:inline-block;
white-space:normal;
border: 1px solid red;
}
.resources_lt {
height:100%;
width:33%;
display:inline-block;
white-space:normal;
margin-right: 20px;
vertical-align: top;
border: 1px solid red;
}
.resources_rt {
height:100%;
width:50%;
display:inline-block;
white-space:normal;
vertical-align: top;
border: 1px solid red;
}
'浮動:left'圖像和應用'clearfix'到容器? – crush
據我所知,當混合百分比和像素時,你無法弄清楚文本的百分比,在光明的一面,如果你將圖像浮動到左邊,你根本不需要給它任何寬度,浮動:左;'。 –
如果您的瀏覽器支持可接受,則可以使用CSS ['calc()'](http://caniuse.com/calc)。 – crush