在div周围包装文字

时间:2013-11-10 02:37:09

标签: html css

希望你能帮助我

我正在尝试创建一个新的

我想在div中添加一个图像到我的文本中。我想要左边的文字和右边的图片。因此,当文本较长时,文本将填充整个内容页面。

希望你明白我的意思

2 个答案:

答案 0 :(得分:1)

你想添加浮动:左;和float:右边的CSS属性。

这是一个显示这一点的小提琴:http://jsfiddle.net/MathiasaurusRex/3W256/

你包装你的< img>在你的< p>标记并以您希望的方式浮动每个标记。

CSS

p{float:left;}
img{float:right;}

HTML

<div>
    <p> <img src="http://lorempixel.com/400/200/"/>"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness."</p>
</div>

答案 1 :(得分:0)

使用内联作为div的显示属性。