html - Flexbox:具有大子元素的两列布局 - 适用于 Chrome,但不适用于 Firefox/IE

标签 html css flexbox

我有一个 2 列 Flexbox 布局。

第一列有一个非常大的子元素(图像)。它之所以大,是因为它在视网膜显示屏上看起来很好。图像使用 max-width:100% 进行缩放。

在 Chrome 中,布局工作正常。但在 Firefox/IE 中,图像破坏了布局。 有什么办法可以让它正常显示吗?

这是布局的 Codepen:http://codepen.io/madhusharma/pen/YXNbVE

这是 HTML:

<div class="container">

<div class="unit-body reading-style">
<div class="unit-aside">
<img src="http://placehold.it/1077x1000"/>
</div>

<div class="unit-main">
<p>Text</p>
</div>
</div>

</div>

这是 CSS:

html {
  box-sizing: border-box;
}
*, *:before, *:after {
  box-sizing: inherit;
}

.container {
  max-width:960px;
  margin:auto;
}

.unit-body {
  display: flex;
  flex-flow: row wrap; 
}

.unit-aside {
    flex: 1 50%;
  padding: 10px;
}

.unit-main {
  flex: 1 50%;
  padding: 10px;
}

img {
  max-width:100%;
  height:auto;
}

最佳答案

尝试从 .unit-body 中删除 flex-flow: row wrap;

此外,似乎 Firefox 处理此问题的方式不正确,我找到了这个答案:https://stackoverflow.com/a/26916542/152016

min-width:0; 添加到 .unit-aside 中,它应该可以工作。

关于html - Flexbox:具有大子元素的两列布局 - 适用于 Chrome,但不适用于 Firefox/IE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30579857/

相关文章:

javascript - 否则条件永远不会被触发

html - 为什么 float 和 inline-block 会导致不同的垂直类型?

javascript - 不使用唯一 ID 影响所选 div 的按钮

html - 下拉菜单只在每个按钮悬停时打开一个下拉框

css - 网页中心框

html - flex column wrap时,如何让第二列不占满第一列的高度?

jQuery 动画链接

javascript - 单击另一个中的处理程序

html - 使用 ngSubmit 在 Angular2 中登录表单

html - 为什么 <fieldset> 不能是 flex 容器?