html - Flexbox parent 收缩得比 children 小

标签 html css flexbox

如何防止这个 flex parent 缩小到小于 children 的高度?灰色容器是 flex 父容器,白色框是子容器。

Flex children extend outside parent

grey box
  display flex

white boxes
  display block
  height 200px

最佳答案

我发现了问题;它是由使用以下规则重置的 css 引起的:

body, html { height: 100%; }

一旦我将其更改为:

,问题就消失了
body { height:auto; min-height:100%; }
html { height: 100%; }

关于html - Flexbox parent 收缩得比 children 小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27131855/

相关文章:

javascript - JQuery如何找到既不是当前元素的父元素也不是子元素的最接近元素?

css - 使图像在 slider 中响应

html - 绝不允许两个元素拆分 CSS3 列

css - Bootstrap : Shrink Column

css - 嵌套列内的 Bootstrap 行,响应高度

html - 根据文本自动调整文本区域大小的 CSS 规则

html - 为什么我的特定选择器不适用于 nth-of-type() 和 nth-child()?

html - 为什么 flexbox 在包装元素时不将后续内容向下推?

html - 我如何使用 flexbox 和媒体查询进行包装?

javascript - 以错误的顺序应用的 CSS 类