ios - Flexbox 在 Safari 和 IOS 中不工作

标签 ios css safari flexbox css-grid

我制作了一个响应式 flex 网格。它适用于 Chrome,但不适用于 Safari 和 IOS。我肯定错过了什么。谁能告诉我我做错了什么?

codepen

section {
  max-width: 1280px;
  display: block;
  margin: 0 auto;
}

section:not(.grid) {
  .wrapper {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    -webkit-box-pack: start;
    -ms-flex-pack: start;
    justify-content: flex-start;
  }
  .box {
    -webkit-box-flex: 1;
    -webkit-flex: 1 1 12em;
    -ms-flex: 1 1 12em;
    flex: 1 1 12em;
  }
}

.wrapper {
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: (minmax(12em, 1fr))[auto-fill];
  grid-template-columns: repeat(auto-fill, minmax(12em, 1fr));
}

.box {
  padding-right: 1em;
}

.box:last-of-type {
  padding-right: 0;
}

最佳答案

从 SCSS 中删除此封闭元素,但保留其中的所有内容:

section:not(.grid) {}

这意味着这些 flex 样式将不会被应用。

section {
  max-width: 1280px;
  display: block;
  margin: 0 auto;
  border: 1px dashed red;
}


  .wrapper {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    -webkit-box-pack: start;
    -ms-flex-pack: start;
    justify-content: flex-start;
  }
  .box {
    -webkit-box-flex: 1;
    -webkit-flex: 1 1 12em;
    -ms-flex: 1 1 12em;
    flex: 1 1 12em;
    border: 1px dashed blue;
  }

.wrapper {
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: (minmax(12em, 1fr))[auto-fill];
  grid-template-columns: repeat(auto-fill, minmax(12em, 1fr));
}

.box {
  padding-right: 1em;
}

.box:last-of-type {
  padding-right: 0;
}
<section class="grid">
  <h4>All projects</h4>
  <div class="wrapper">
    <div class="box">
      <h5>Project 1<br>
			<span>Category</span>
			</h5>
    </div>
    <div class="box">
      <h5>Project 2<br>
				<span>Category</span>
				</h5>
    </div>
    <div class="box">
      <h5>Project 3<br>
				<span>Category</span>
				</h5>
    </div>
    <div class="box">
      <h5>Project 4<br>
				<span>Category</span>
				</h5>
    </div>
    <div class="box">
      <h5>Project 5<br>
				<span>Category</span>
				</h5>
    </div>
    <div class="box">
      <h5>Project 6<br>
				<span>Category</span>
				</h5>
    </div>
  </div>
</section>

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

相关文章:

html - 如何仅为 Safari 添加 css 行

css - 如何使用 Bootstrap 调整每行的列数

html - Bootstrap 布局不适用于 Safari

ios - Popcorn JS - 在 iPad 或 iOS 设备上通过 Youtube 使用爆米花

javascript - 在 Safari App Extension 中以编程方式加载弹出窗口

ios - 架构 i386 的 undefined symbol ,仅在 iPad 模拟器上

iOS - iPad 的 viewWillTransition 中错误的 UIScreen 边界

ios - Mac OS X 代码签名是否像 iOS 上的代码签名一样工作?

javascript - 将显示设置为内联提交表单但不阻止

ios - 用于了解 Xcode 4.3.2 中是否启用 ARC 的宏