Why does adding overflow: hidden make the child element's margin work?
问题 When I add an element like h1 with margin: 30px 0; , the margin goes outside the container! I faced this problem many times before, and I solved it by using overflow: hidden I want to figure out what's the problem and why this solution works? Find a JSFiddle here https://jsfiddle.net/LeoAref/zv6c2c2d/ .container { background: #ccc; } .container.overflow { overflow: hidden; } .secTitle { margin: 30px 0; } code { color: blue; } <!-- secTitle margin goes outside the container --> <div class=