html - Flexbox 在 Safari 中不工作

标签 html css safari flexbox

我正在创建的布局在 Safari 中不起作用,尽管它在 Chrome 中运行良好。我感觉它与 .wrapper.frame 有关,但我尝试将 Flex Shrink 值设置为 0 以徒劳无功。

JSFiddle

.frame {
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    height: 100vh;
    position: relative;
    overflow: hidden;
    -webkit-flex: 1 1 auto;
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    -webkit-flex-wrap: nowrap;
    -ms-flex-wrap: nowrap;
    flex-wrap: nowrap;  
    -webkit-flex-flow: column nowrap;
    -ms-flex-flow: column nowrap;
    flex-flow: column nowrap;
    -webkit-align-items: stretch;
    -ms-flex-align: stretch;
    align-items: stretch;
    -webkit-justify-content: flex-start;
    -ms-flex-pack: start;
    justify-content: flex-start;
    -webkit-order: 0;
    -ms-flex-order: 0;
    order: 0;
}

.wrapper {
    -webkit-flex: 1 0 auto !important;
    -ms-flex: 1 0 auto !important;
    flex: 1 0 auto !important;
    -webkit-flex-wrap: nowrap !important;
    -ms-flex-wrap: nowrap !important;
    flex-wrap: nowrap !important;
}

.row, 
.wrapper {
    box-sizing: border-box;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-flex: 0 0 auto;
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -webkit-flex-direction: row;
    -ms-flex-direction: row;
    flex-direction: row;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
}

我也觉得可能有一种更好的方法可以在不需要包装器的情况下使用 Flexbox,但我无法理解它。

非常感谢任何帮助!

最佳答案

问题出在您的 .content 类上。具体来说,在这段代码中。

.content {
    display: block;
  flex: 1 1 auto;
  background: #ddd;
  height: auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right:.5em;
  padding-bottom:.5em;
}

Safari 仍然需要 -webkit- 前缀才能使用 flexbox .因此,您需要为 flex 属性添加 -webkit- 前缀。

示例 ( JSFiddle ):

.content {
    display: block;
  -webkit-flex: 1 1 auto;
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  background: #ddd;
  height: auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right:.5em;
  padding-bottom:.5em;
}

关于html - Flexbox 在 Safari 中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28976288/

相关文章:

ios - 创建 Safari Webarchives 的跨平台方式

safari - 我需要一个苹果脚本来全屏打开 safari 并隐藏小牛上的工具栏

html - 如何固定自定义侧边栏位置

javascript - Polymer v1.0 单击按钮时的输入验证

c# - 非静态字段、方法或属性需要对象引用 'MyClass.SetImageUrl()'

jquery - 如何将表格行中的文本居中,使其始终位于屏幕可见区域的中心

html - IE 11 上显示的字体大小与其他浏览器不同

html - 除非 html 包含类,否则应用 CSS

html - 为什么我不能选择类为 'offer' 的第一个 div?

javascript - 在 Safari IOS12 上禁用双击缩放/调整大小***