如何使用CSS水平对齐图像旁边的文本

时间:2013-01-17 09:03:24

标签: html css

enter image description here

如何将图像旁边的文字与附加的screnshot一样垂直对齐。

Ex:我曾在这篇文章中附上了screnshot。

4 个答案:

答案 0 :(得分:2)

将图像浮动并将overflow:hidden放在文本上以防止它出现在图像下方。

答案 1 :(得分:0)

将此CSS样式用于图像

clear:both

答案 2 :(得分:0)

简单浮动通常可以解决问题

img { 
     flaot:left;
}
p {
   flaot:left;
}

这甚至会使文本添加到图像中,因此如果文本比图像的高度长,它将在它下面扭曲。

答案 3 :(得分:0)

<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>

测试一下。