I have the following code. I can't figure out why the top position of div1 in the second block is different from the first one. When div1 in child1 contains text or other elements, the top position of div1 and div2, div3 is equal. Can someone explain the reason behind this? Thank you!
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
* {
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>
<div id='parent' style='width: 100%;height:100%;background-color:blue;position:absolute;'>
<div id='child1' style='margin:auto auto;background-color:red;margin:10px;padding:10px;'>
<div id='div1' style='width:50px;height:30px;background-color:grey;display:inline-block;'></div>
<div id='div2' style='width:200px;height:30px;background-color:green;display:inline-block;'>
<input type='text' value='Text' />
</div>
<div id='div3' style='width:50px;height:30px;background-color:green;display:inline-block;'>Text</div>
</div>
<div id='child2' style='margin:auto auto;background-color:red;margin:10px;padding:10px;'>
<div id='div1' style='width:50px;height:30px;background-color:grey;display:inline-block;'>Text</div>
<div id='div2' style='width:200px;height:30px;background-color:green;display:inline-block;'>
<input type='text' value='Text' />
</div>
<div id='div3' style='width:50px;height:30px;background-color:green;display:inline-block;'>Text</div>
</div>
</div>
</body>
</html>