我目前得到父 div 高度:height: inherit;,但是当我缩小窗口时,父 div 小于容器 div,所以溢出:隐藏;隐藏一半的容器内容。
是否可以仅使用 css 来实现?
这是代码:
<div id="container">
<div class="content">
<div class="wrapper">
Content here
</div>
</div>
#container {
float: left;
height: 400px;
width: 400px;
background-color: red;
}
.content {
float: left;
height: inherit;
width: 90%;
overflow: hidden;
position: relative;
background-color: black;
}
.wrapper {
width: 90%;
height: 900px;
position: relative;
z-index: 99;
background-color: blue;
}
最佳答案
您可能使用 overflow
属性来清除 float ,对吗?
然后将overflow: hidden
改为overflow: auto
。
关于CSS - 容器高度与父 div 高度相同,除非父 div 小于容器 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30598298/