html - 为什么在这个 flex-column 方向示例中 height 属性会覆盖 flex-basis
问题描述
在下面的示例中,我有一个带有 flex-direction:column 的 flex 容器,对于 flex-item 有 flex-basis 和 height
我希望 flex-basic 会覆盖 height 但完全相反的 height:8px 会覆盖 flex-basis:7px我不知道原因!我预计弹性项目不会缩小,因为孩子的高度为 10px,但发生了!
https://jsfiddle.net/5y47jke0/
.flex-container
{display: flex;justify-content: center;flex-direction: column;background: green;height: 200px;}
.flex-item {
flex-basis: 7px;
max-height: 55px;
height: 8px;
}
.flex-item2
{background: #ffeb00;height: 14px;width: 120px;}
.flex-item-child
{height: 10px;}
.image
{height: 10px;}
.container
{
position: relative;
left: 300px;
top: 100px;
background: red;
}
<div class="container">
<div class="flex-container">
<div class="flex-item">
<div class="flex-item-child">
<img src="https://i.postimg.cc/rmh60Y7w/mobile.png" alt="" class="image">
</div>
</div>
<div class="flex-item2">
</div>
</div>
</div>
解决方案
推荐阅读
- python - Python 继承,具有基类 init 始终调用的 set_up() 方法,同时在子类中具有不同的参数
- file - 如何将二进制数据块组合成一个复合文件
- anaconda - Anaconda 安装错误 - conda-script.py [-h] [-V] 命令
- python - 使用 PIL 进行 RGB 处理 - 如何获取单个图像并生成具有不同 RGB 值的图像?
- c++ - 对原子变量的非原子操作,反之亦然
- google-apps-script - 使用 Google Apps 脚本发送电子邮件 - Gmail API
- swiftui - SwiftUI:插入过渡动画未执行
- jenkins - Jenkins Pipeline 将字符串数组传递给函数
- react-native - 像 Instagram 上的 React Native 底部标签栏
- sql - 按 id 和某些条件过滤掉数据分组