Child margin adding margin to parent

后端 未结 2 780
别跟我提以往
别跟我提以往 2021-01-22 19:44

how if i have the following code : HTML :

Hello

2条回答
  •  孤街浪徒
    2021-01-22 20:27

    http://jsfiddle.net/naeemshaikh27/qbaucv3j/1/

      .main{
            overflow: hidden; 
            height: 100%;
            background: pink;
        }
    

    This is normal behaviour (among browser implementations at least). Margin does not affect the child's position in relation to its parent, unless the parent has padding, in which case most browsers will then add the child's margin to the parent's padding.

    source https://stackoverflow.com/a/1939980/3556874

提交回复
热议问题