css高度自适应问题 百分比高度
本文介绍了css高度自适应问题 百分比高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
父级div为1,里面有2个子div
3的高度根据内容自适应
1的高度根据3的高度自动撑开并设置最小高度45
2的高度跟1一样高
解决方案
<div class="one">
<div class="two"></div>
<div class="three"></div>
</div>
.one {
position: relative;
min-height: 200px;
}
.two {
background-color: green;
position: absolute;
top: 0px;
left: 0px;
right: 50%;
bottom: 0px;
}
.three {
height: 300px;
width: 50%;
background-color: red;
margin-left: 50%;
min-height: 200px;
}
你可以调节.three height
的大小查看效果。
这篇关于css高度自适应问题 百分比高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文