html - iOS 上 Safari 的奇怪的边距底部行为

标签 html ios css safari margin

我的 body 中有类似的东西(简体)

<div id="container">
  <article>
    text
  </article>
</div>

用 css

#container > article
  margin-bottom: 50px
  overflow: auto

article
  display: block

在所有浏览器上,margin-bottom 都会显示,但 Safari 似乎会折叠它。

我阅读了很多关于此问题的信息,但 overflow: auto 并没有立即提供帮助或任何其他技巧。

如果我将 margin-bottom 移动到 css 中的 article 定义,事情会变得非常奇怪,在这种情况下,Safari 会显示边距。..

#container > article
  /* nothing remains here */

article
  display: block
  margin-bottom: 50px
  overflow: auto

这不是我想要的,因为它会影响 所有 article 标签。

如果有人可以向我解释这一点,并有一个解决方法来实际使 Safari 按预期运行,那将不胜感激。

最佳答案

我在其他浏览器上也遇到过这种情况。似乎“如果没有什么可以反弹”,margin-bottom 不起作用。

我的解决方案总是为父元素添加一个小填充。然后边距在填充上反弹。

所以尝试添加:

#container {
  padding-bottom: 1px;
}

关于html - iOS 上 Safari 的奇怪的边距底部行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49153426/

相关文章:

html - 如何链接我的 flexbox css 和 html 类?

javascript - 使用 call 或 apply 调用 jQuery 函数

ios - 将容器置于其他容器之上

javascript - 从绝对位置 div 算起的图像高度

javascript - super 简单的音频播放器吗?

html - 纯CSS下拉展开div背景

ios - NavigationBar 为一个 View 设置 TitleColor

ios - Paypal iOS SDK - 验证付款

html - <a tag> 的 css 增加宽度和高度?

html - FTP 到服务器后,index.html 无法从 CSS 读取