<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>
10 回答11.7k 阅读
2 回答3.2k 阅读✓ 已解决
2 回答4.2k 阅读✓ 已解决
5 回答2.2k 阅读
3 回答1.9k 阅读✓ 已解决
3 回答1.7k 阅读✓ 已解决
3 回答2.7k 阅读✓ 已解决
height: 100%
height: 100vh
或者父元素relative, 子元素absolute像狗皮膏药一样贴上去。