如何用CSS包装图像内容?带有类.header
的Div应该用它内部文本的宽度换行边框。课程.body
的Div应位于.header
div。
<div class="block">
<div class="image">
<img src="http://i.stack.imgur.com/SZHzX.jpg" />
</div>
<div class="text">
<div class="header">
Here is header bar
</div>
<div class="body">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</div>
</div>
CSS:
.image {
float: left;
}
.header {
border: 1px solid #000;
margin-bottom: 20px;
}
提前致谢,抱歉我的英语不好。
答案 0 :(得分:0)
使用display:table-cell
.image {
display: table-cell;
vertical-align:top;
padding-right:5px;
}
.header {
border: 1px solid #000;
margin-bottom: 20px;
display:inline;
}
.text{display: table-cell; vertical-align:top;}
答案 1 :(得分:0)
使用填充图像
.image { padding-right:10px; }