<head>
<style>
.fa{
width: 100%;
height: 100%;
margin: 0 auto;
}
.son{
width:90%;
position: absolute;
/* 如果son盒子上边还有其他内容,top值要留出距离父盒子顶部其他内容的px值 */
top: 0;
/* bottom值同理,也可以用百分比表示距底部留出空白的值 */
bottom: 0;
}
/* 之盒子当中的sun盒子高度问题,只需要用百分比选择,就可以实现与子盒子一起变化的效果 */
</style>
</head>
<body>
<div class="fa">
<div class="son">
<div class="sun"></div>
</div>
</div>
</body>
强制实现子元素高度自适应屏幕高度
最新推荐文章于 2023-06-29 08:43:53 发布