当我的文本字符串太长时,它会位于图像下方,而我希望它换行并保持在图像右侧。当文本变得太长时,如何使文本继续留在图像的右侧而不是位于该“race2.jpg”图像下方?我想如果一切都失败了,可以用换行符来完成,但还有其他方法吗?
JSFiddle:http://jsfiddle.net/fgGyF/
HTML:
<div id="rightcolumn">
<div id="supportus">
<h6>Support Us</h6>
<div style="float: left">
<img src="images/race2.jpg" width="180" height="360" />
</div>
<div style="float:left; text-align: left">
Test text here. And here and here and here and here and here.
</div>
</div>
CSS:
#leftcolumn {
width: 50%;
float: left;
}
#rightcolumn {
width: 50%;
float: left;
}
#twitter {
min-height: 250px;
margin-top: 10px;
margin-right: 15px;
}
#whatsnew {
min-height: 500px;
background: #f0f7cb;
outline:#FFFFFF solid thick;
margin-top: 15px;
margin-right: 15px
}
#supportus {
min-height: 445px;
margin-top: 10px;
margin-bottom: 20px;
background: #f0f7cb;
outline:#FFFFFF solid thick;
}
#dianerehm {
min-height: 200px;
background: #f0f7cb;
outline:#FFFFFF s
最佳答案
只需为带有文本的 div 分配设置的宽度。
<div style="float:left; width:140px; text-align: left">
Test text here. And here and here and here and here and here.
</div>
关于html - CSS 定位 : Too long text string puts text beneath image, 不在旁边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23021656/