I have code below. I don't know why the top position of div1 in 2 block are not the same. If div1 in child1 contains text or other element(s), the top position of div1 and div2, div3 is equal. Please show me the reason. Thank you so much.
<!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>