2010-09-17 84 views
4

这可能是一个简单的问题,但我无法弄清楚。我想使用CSS将图片放在页面的右侧,而不是将文字包裹起来。我想这样的:CSS - 图片在页面右侧,文字没有环绕它

 
       ------------ 
       | img | 
       |   | 
       ------------ 
text text text text text text 
text .... 

如果我做了浮动:右侧的图像上,我得到这个:

 
text text text ------------ 
text text text | img | 
text text text |   | 
text text text ------------ 
text text text text text text 
text ... 

我可以很容易地使用表来做到这一点,但我想纯CSS。

回答

10

类似的东西来这应该工作:

<div> 
    <div style="width: 100%"> 
    <img style="float:right;"> 
    </div> 
    <div> 
    text 
    </div> 
</div> 
5
<div> 
     <img src="img.jpg" style="float:right;" /> 
     <div style="clear:right;"> 
      <!-- text here --> 
     </div> 

</div> 

吧?

+0

This works too! – Starkey 2010-09-17 21:10:31