用绝对定位和margin:auto,使子元素垂直水平居中,子元素比父元素大,并且设置了滚动,代码如下。
问题:为什么垂直方向的上方被屏蔽了,而水平方向并没有。
看图,margin-left 为0;margin-right:为被滚动的宽度。但是margin-top和margin-left,是均分的。那我想要解决被屏蔽的问题,怎么办?

<!DOCTYPE html>
<html>
<body>
<div class="parent">
<div class="child">
<div>
im a coconut
</div>
</div>
</div>
<style>
.parent {
width: 500px;
height: 500px;
background-color: black;
position: relative;
overflow: auto;
}
.child {
width: 800px;
height: 800px;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
background-color: brown;
border: 3px solid black;
box-sizing: border-box;
}
</style>
</body>
</html>