Margin goes outside div when border is removed

前端 未结 4 1891
后悔当初
后悔当初 2021-01-21 13:43

Derived from an actual problem with borders and margin on my site I have made this test example which I think acts a little strange:




        
4条回答
  •  孤独总比滥情好
    2021-01-21 14:10

    Because margins are evil (and tend to collapse -> is it a bug? margins of P element go outside the containig div). In your case you can simply add overflow:hidden; to .outer

    http://jsfiddle.net/yhAaQ/

提交回复
热议问题