2013-03-15 98 views
1

我需要围绕已向下推动的浮动元素显示文本。在HTML/CSS很简单:如何解决此Safari浏览器浮动渲染问题

<div id="container"> 
    <div id="shim"></div> 
    <div id="myimg"></div> 
    <p>This is a test to demonstrate the float overwriting issue. The blue box represent an image that I don't wish the text to overwrite...</p> 
</div> 

CSS:

#container { 
    width: 200px; 
} 

#shim { 
    float:right; 
    width: 1px; 
    height: 40px; 
    background-color: red; 
} 

#myimg { 
    clear:both; 
    float:right; 
    width: 100px; 
    height: 40px; 
    background-color: blue; 
} 

它完美地在Chrome和Firefox,但在Safari中的文本覆盖我的浮动元素。

我创建了一个小提琴证明了这个错误(显然,你需要野生动物园看到它):

http://jsfiddle.net/8JLFp/

任何人都可以找到一个解决方案或建议这样做的另一种方式?

+0

它看起来不错的Safari与Chrome的预期5.1.7 – Sowmya 2013-03-15 10:03:19

+0

的Safari 6.0.2不工作。 – soyuka 2013-03-15 10:03:44

+0

它使用Safari 6.0.2。它不适用于该版本。 – tarmes 2013-03-15 10:09:33

回答

1

Please check the same issue on this site. May be this helps you.

可能的解决方案。

  1. 尝试增加明确:双方的div
  2. 使用溢出:隐藏
+0

嗯,将这些DIV添加到哪里?不知道如何溢出:隐藏将有所帮助.. – tarmes 2013-03-15 10:10:19

+0

div {overflow:hidden} ...将此添加到css中。 – 2013-03-15 10:12:15

+0

您是否在2008年9月11日JANENE所说的链接中尝试了解决方案。 – 2013-03-15 10:14:26