css - flex 元素中的意外滚动行为
问题描述
有人可以解释为什么顶部被截断:
https://jsbin.com/yuhexoz/edit
<div
style="
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
position: relative;
top: 100px;
left:100px;
width:200px;
height: 200px;
background: green;
overflow: auto;
">
<div
style="
height:400px;
margin: 40px 0;
height:430px;
width: 100px;
background: red;
border: solid 10px;
">
</div>
</div>
我设法在这里修复它,但我仍然想知道导致这种行为的原因:
https://jsbin.com/finujeq/edit
<div
style="
position: relative;
top: 100px;
left:100px;
width:200px;
height: 200px;
background: green;
overflow: auto;
">
<div style="
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
min-height: 100%;
">
<div
style="
margin: 40px 0;
height:430px;
width: 100px;
background: red;
border: solid 10px;
">
</div>
</div>
</div>
解决方案
推荐阅读
- python - 堆叠两个框架,一个有行和列的框架和一个没有的框架
- android - 在 bottomSheetScaffold 中设置背景透明
- java - 如何从 Firebase 和 recyclerview Android Studio 中删除数据
- typescript - 为单行禁用 `noImplicitAny` TS 规则
- flutter - 如何在 Flutter 中使用 GetX 观察 GetxController 类中的值变化并触发 statelessWidget 类中的导航?
- javascript - 如何在同一页面中使用多个 splidejs 滑块?
- c# - 从会话中获取所有登录用户
- javascript - Vue:如何在挂载钩子之前使用 mapState 的值?
- typescript - VueJS 编译失败:找不到依赖项
- html - 标签未在文本输入上方的左上角对齐