html - 如何解决这个 Safari float 渲染错误

标签 html css

我需要在本身已向下推的 float 元素周围显示文本。 HTML/CSS 非常简单:

<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 中,文本会覆盖我的 float 元素。

我创建了一个 fiddle 来演示这个错误(显然,你需要 safari 才能看到它):

http://jsfiddle.net/8JLFp/

任何人都可以找到解决方案或建议另一种方法吗?

最佳答案

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

可能的解决方案。

  1. 尝试添加 clear:both div
  2. 使用溢出:隐藏

关于html - 如何解决这个 Safari float 渲染错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15429344/

相关文章:

html - 如何在没有 JavaScript 的情况下清除已经发送到浏览器的 HTML 内容?

php - 如何将多个 sql 查询链接到 html 选择表单?

html - Css 下拉导航栏菜单

css - 可以使用断字 :break-all 将单词打断到 50%

html - 'display: block; float: left' 与 'display: inline-block; float: left' 之间的区别?

javascript - 使用 javascript 添加 CSS 渐变 - IE7 中的错误

javascript - 如何将 Angular 与 HTML5 地理定位原生 API 结合使用?

css - 包装器 div 没有完全包围它的 child

css - 开始使用 effeckt.css - 了解文档吗?

javascript - 如何将图片库放入 Bootstrap Modal 中?