1. 程式人生 > 其它 >高度塌陷和外邊距摺疊的完美解決程式碼

高度塌陷和外邊距摺疊的完美解決程式碼

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>高度塌陷和外邊距摺疊的完美解決程式碼</title>
        <style>
            .box1{
                border: 1px red solid;
            }
            
            .box2{
                width: 200px;
                height
: 200px; background-color: #ff0; float: left; } .box3{ width: 300px; height: 300px; background-color: orange; /* clear: both; */ } .clearfix
{ content: ''; display: table; clear: both; } </style> </head> <body> <div class="box1 clearfix"> <div class="box2"></div> <div class="box3"></div> </
div> </body> </html>