It is often possible to encounter such a problem, that is, the outer div set the height and width, the inner div If set maring-top does not work (Firefox and IE8 test), the reason is that the inner Div does not get the layout. As in the following code:
<style>
. adiv {background:red; width:300px; height:300px;}
. bdiv {background:green; position:relative; width:100px; height:20px; margin-top:10px;}
. cdiv {background:black; position:relative; width:100px; height:20px;}
</style>
<div class= "Adiv" >
<div class= "Bdiv" ></div>
<div class= "Cdiv" ></div>
</div>
The test found that Bdiv's margin-top did not work, and was still the 0px display effect. If you use Firebug to view in Firefox, you can see that margin-top is a value, 10px; The problem is as follows:
1, change the margin-top to Padding-top, however, the premise is that the inner Div does not set the border
2. Add padding-top to the outer div
3. Add to the outer div:
A, Float:left or right
B, Position:absolute
C, Display:inline-block or Table-cell or other table types
D, Overflow:hidden or Auto
About the inner div setting margin-top does not work solution