Margin on child element moves parent element

前端 未结 14 2479
广开言路
广开言路 2020-11-21 23:38

I have a div (parent) that contains another div (child). Parent is the first element in body with no

14条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 00:31

    The margin of the elements contained within .child are collapsing.

    
    
    
    

    &

    &

    In this example, p is receiving a margin from the browser default styles. Browser default font-size is typically 16px. By having a margin-top of more than 16px on #child you start to notice it's position move.

提交回复
热议问题