并列盒子的margin(雙margin的重疊)面試題:一個盒子有上邊距,另一個盒子有下邊距,會出現margin邊距的重疊問題?解決:取大值,并不是他們的相加之和,而是誰大聽誰的!
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title></title> <style type="text/css"> *{margin: 0;padding: 0;} .box1,.box2{ width: 200px; height: 200px; } .box1{ background-color: #f90; margin-bottom: 20px; } .box2{ background-color: aqua; margin-top: 50px; } </style> </head> <body> <div class="box1"></div> <div class="box2"></div> </body> </html>

margin跟padding內邊距的方位值和取值情況一樣,順時針方向(上右下左),點擊查看"css盒子模型之內邊距padding及簡寫"
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/194172.html
標籤:Html/Css
