bug--margin塌陷

<!DOCTYPE html>
<html lang="en">
<head>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .wrapper{
            height: 200px;
            width: 200px;
            background-color: black;
            margin-left: 50px;
            margin-top: 50px;

            /*在父級加個頂,設(shè)置上邊框,然后顏色設(shè)置為透明transparent,嘿嘿*/
            /*這樣確實能達到目的,但是差1像素,還是不合格*/
            /*border-top: 1px solid red;*/
        }
        .content{
            width: 100px;
            height: 100px;
            background-color: green;
            margin-left: 20px;
            /*問題出現(xiàn)這這里*/
            margin-top: 20px;
            /*只有 margin-top 的值大于父級的 margin-top 的值時才有效*/
            /*并且會帶著父級一起向下*/
            /*margin-top: 120px;*/
            /*margin-top: 300px;*/
            /*margin 沒有“頂”*/

            /*那就在父級加個頂???設(shè)置上邊框,然后顏色設(shè)置為透明transparent,嘿嘿*/

            /*這個也無效*/
            /*margin-bottom: 10px;*/
        }
    </style>
    <meta charset="UTF-8">
    <title>bug--margin塌陷</title>
</head>
<body>
    <div class="wrapper">
        <div class="content"></div>
    </div>
</body>
</html>
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容