<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test</title>
</head>
<style>
.abs-par {
position: absolute;
width: 100%;
left: 0;
top: 0;
}
.abs-son {
position: absolute;
right: 0;
top: 0;
width: 200px;
height: 1000px;
border: 3px solid gold;
}
</style>
<body>
<div class="abs-par">
<div>
<div class="abs-son"></div>
</div>
</div>
</body>
</html>
父元素显示的高度已经是零了,为什么还能撑出滚动条。
问题一:可以实现父元素高度被子元素撑开吗?
问题二:浏览器这种被绝对定位的元素撑出现滚动条的效果怎么实现的?
滚动一般来说可以表示为窗口滚动window,全局文档滚动documentElement,局部元素滚动Element。
你虽然脱离了文档流,但是你还在窗口内啊,还是会引起滚动。
还有,个人觉得文档流是解释盒子模型元素布局排列的,跟滚动其实没有强关联关系。