兼容性—margin
阿新 • • 發佈:2017-05-12
order log 屬性 layout 觸發 com itl img nbsp
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> .box{ background: blue; } .content{ height: 40px; background: red; margin: 50px; }</style> </head> <body> <div class="box"> <div class="content"></div> <div class="content"></div> </div> </body> </html>
所有瀏覽器顯示效果都一樣
給父級加上border屬性,除IE6/7以外都可正常顯示,可以通過overflow和zoom觸發BFC和layout屬性解決
.box{ background: blue; overflow: hidden; zoom: 1; }
兼容性—margin