<div class="father">
<div class="son"></div>
</div>
father的高度是屏幕高度
son的高度是内容高度
现在想让son继承father的高度
怎么做?
<div class="father">
<div class="son"></div>
</div>
father的高度是屏幕高度
son的高度是内容高度
现在想让son继承father的高度
怎么做?
<style type="text/css">
.father{
height: 500px;
width: 500px;
background: #ccc
}
.son{
width: 500px;
background: #f00;
height: inherit;
}
</style>
<body>
<div class="father">
<div class="son"></div>
</div>
13 回答12.7k 阅读
2 回答4.9k 阅读✓ 已解决
5 回答1.3k 阅读
3 回答2.1k 阅读✓ 已解决
8 回答2.2k 阅读
5 回答666 阅读
3 回答2.1k 阅读
height: 100%
height: 100vh
或者父元素relative, 子元素absolute像狗皮膏药一样贴上去。