如何使用 CSS(如附加的截图)垂直对齐图像旁边的文本。
例如:我在这篇文章中附上了截图。
将图像向左浮动并放在overflow:hidden
文本上以防止它进入图像下方。
为图像使用此 CSS 样式
clear:both
一个简单的浮点数通常可以解决问题:
img {
float: left;
}
p {
float: left;
}
这使文本适应图像。如果文本比图像的高度长,它将在它下面换行。
<p><img src="https://www.google.com/images/srpr/logo3w.png" style="float:left;padding-right:12px" width="280" />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.</p>
<br style="clear:both" />
<p>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.</p>
测试这个。