
双列布局下如何让右侧高度等同于左侧
在此提供的 html 和 css 代码中,问题在于右侧块(.right)没有指定高度。为了使其高度与左侧块(.left)相同,需要进行以下调整:
修改后的代码:
.parent {
display: flex;
height: 200px;
border: solid darkcyan 1px;
overflow-y: auto;
}
.left {
background: lightblue;
height: 300px;
width: 50%;
}
.right {
width: 50%;
background-color: lightcoral;
}
.box {
display: flex;
}添加新的容器 .box,并将 .left 和 .right 嵌套在 .box 中。.box 容器将撑开父元素(.parent)的高度,使得 .left 和 .right 的高度与 .box 相同。










