我想为 div 设置最大高度,就像在代码中一样设置高度自动。
.background.left-sidebar {
height: auto !important;
padding-bottom: 0;
right: 0;
width: 300px;
background-color: #999999;
margin-top: 40px;
margin-right: 300px;
}
.left-sidebar {
height: auto;
width: 300px;
padding-bottom: 0px;
}
.left-sidebar-top {
width: 100%;
height: 300px;
background-color: #996699;
}
<div class="right_block left-sidebar">
<div class="content">
<div class="top_block left-sidebar-top">
<div class="content">
</div>
</div>
<div class="marker">This</div>
</div>
</div>
我尝试设置height:100%
、height:auto
,但不起作用。
如何在 CSS 中设置 height auto 的最大高度?
最佳答案
你可以尝试:
height : 100vh;
将您的 div 设置为视口(viewport)的 100%
关于css - 如何在 CSS 中设置 height auto 的最大高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39163244/