简体   繁体   English

防止文字环绕浮动图片

[英]Keep text from wrapping around floated image

I currently have an image that is floating left, and a block of text that rests to the right of it. 我目前有一个向左浮动的图像,在其右侧保留了一块文本。 That block of text is not current floated, it just comes after the image in the HTML. 该文本块不是当前浮动的,而是紧随HTML中的图像之后。 So as it gets longer it eventually kicks over to the left under the image to continue on. 因此,随着时间的延长,它最终会移到图片下方的左侧以继续。

How can I make it so the block of text always stays to the right of the image, so the image and the text behave like two side-by-side columns? 如何使文本块始终位于图像的右侧,以便图像和文本的行为像两个并排的列? Bear in mind that I cannot do anything outside of these two elements. 请记住,我不能在这两个要素之外做任何事情。 I cannot add a wrapper around them. 我不能在它们周围添加包装纸。 I can add elements before, between, or after. 我可以在元素之前,之间或之后添加元素。 But not around. 但是没有。

Thanks. 谢谢。

p
{
width:1000px;
display: table-row;       
}

FIXED ANSWER 固定答案

Just float the text as well. 只需浮动文本。 :) :)

http://jsfiddle.net/Hs7pN/ http://jsfiddle.net/Hs7pN/

#image
{
    background-color: #09C;
    float: left;
    height: 200px;
    width: 200px;
}

#text
{
    float: left;
    width: 400px;
}

尝试设置固定宽度(如果可能),然后对齐文本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM