Here is my html and css code is below:
<!DOCTYPE HTML>
<html lang="en">
<head>
<style>
body{
background-color: deepskyblue;
}
.main{
background-color: black;
color: white;
width: 100px;
height: 100px;
}
.inside{
background-color: orangered;
width: 50%;
height: 50%;
margin: 25%;
}
</style>
</head>
<body>
<div class="main">
<div class="inside"></div>
</div>
</body>
</html>
I want it looks like:
But it actually looks like:
I am not asking how to fix it (I know I can using "position" to solve it). My question is why vertically the "inside" div box does not goes to center? From the inspect I can see that the margin(top) of "inside" does not based on "main" div box. However, horizontally the margin(left) of "inside" is based on "main" div box. I would like to know the concept of this.