I think I've got some confusion on how margin auto works. In this case, I'm creating a parent div and a children div inside of it, and both div boxes are given width & height. Then, I tried to use margin auto to make the inner div horizontally & vertically aligned.
<div id="parent">
<div id="child"></div>
</div>
#parent {
width: 200px;
height: 200px;
background: red;
}
#child {
width: 50%;
height: 50%;
background: blue;
margin: auto;
}
Somehow the result was out of my expectation. Anyone knows why?