【发布时间】:2021-07-12 19:48:51
【问题描述】:
我的代码:
<head>
<style>
*, *:before, *:after {
box-sizing: border-box;
}
html{
background-color: #aaa;
width: 100%;
height: 100%;
}
body {
background-color: #aaa;
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
}
.item {
background-color: #fff;
}
.d-flex-column {
display: flex;
flex-direction: column;
}
.d-flex-row{
display: flex;
flex-direction: row;
}
.w-100{
width: 100%;
}
.h-100{
height: 100%;
}
</style>
</head>
<body>
<div class="d-flex-row w-100 h-100" style="gap: 0.5em;">
<div class="d-flex-column h-100" style="flex: 1; gap:0.5em;">
<div class="item" style="flex:2;">2</div>
<div class="item" style="flex:1;">1</div>
<div class="item" style="flex:1;">1</div>
</div>
<div class="d-flex-column h-100 " style="flex: 1; gap:0.5em;">
<div class="item" style="flex:3;">3</div>
<div class="item" style="flex:1;">1</div>
</div>
</div>
</body>
如果您仔细观察,右下角的项目的高度与左边的大小不同。 我什至可以使用“flex:x;”和“差距”?
我知道我可以通过“display: grid;”实现同样的效果但我想了解我做错了什么。
【问题讨论】: