我在视口中将父元素的高度设置为90vh,并将子元素的高度设置为90%,但是这个元素没有占据这么多空间,只显示一条线。我对父元素的高度感到困惑,因此子元素必须与其相应。
<div className="min-h-[80vh]">
<div className="h-[90%]">test</div>
</div>
有两个问题阻止了您的代码实现您想要的功能:
.min-h-80vh {
background-color: seagreen;
height: 80vh;
}
.h-90 {
background-color: coral;
height: 90%;
}
<div class="min-h-80vh">
<div class="h-90">test</div>
</div>
position:relative
吗? - Garr Godfrey