Both parent and child have box-sizing: border-box;. According to MDN:
<percentage> Defines the height as a percentage of the containing block's height.
Then the child's height should be 500px as well, but obviously it's not, it has the height of the parent's content height, not parent's height. Having tried this code on many browsers including IE, they all work the same, why is that?
<!DOCTYPE html>
<html lang="zh-Hans">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://unpkg.com/ress/dist/ress.min.css" />
<title>Test</title>
<style>
body {
background: #000;
}
.parent {
border: 50px solid blue;
padding: 20px;
width: 500px;
height: 500px;
background: green;
overflow: auto;
}
.child {
background: red;
height: 100%;
}
</style>
</head>
<body>
<div class="parent">
<div class="child"></div>
</div>
</body>
</html>
