0
我簡單地使用內聯塊設計一個HTML頁面以使其響應。我將所有塊形式的圖像和文本設置爲內聯塊,但文本塊被移動到圖像塊下,我如何設置CSS並將文本塊放在圖像塊旁邊?使用內聯塊的自適應設計
演示:http://jsfiddle.net/yckelvin/ar1f3uz5/
HTML代碼
<div class="item-row">
<div class="item-li"><img src="https://3.bp.blogspot.com/-t9e7S8huhaQ/VBMVN6CbNGI/AAAAAAAAA14/02am46_jiJM/s1600/Big_smile.png" width="150" height="150" /></div>
<div class="item-desc" ><h1>Item 1</h1>
Description Description Description Description Description Description Description Description Description Description </div>
</div>
<div class="item-row item-indent-row">
<div class="item-li"><img src="https://3.bp.blogspot.com/-t9e7S8huhaQ/VBMVN6CbNGI/AAAAAAAAA14/02am46_jiJM/s1600/Big_smile.png" width="150" height="150" /></div>
<div class="item-desc"><h1>Item 2</h1>
Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description </div>
</div>
CSS代碼
.item-row { display: block; width: 100%; padding: 30px; background-color: rgba(0,0,0,0.1); }
.item-indent-row { padding-left: 150px; }
.item-li {display: inline-block; width:50px; background-color: rgba(255,255,0,0.1); }
.item-desc {display: inline-block; background-color: rgba(0,0,255,0.1); padding-left: 0px;}
實際樣品
'float:left' ?? – timgavin 2014-09-30 04:00:51
我嘗試了浮動,但無法控制圖像塊旁邊的文本塊。 – Kelvin 2014-09-30 04:05:37