纯CSS实现Div高度根据自适应宽度(百分百调整)

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>纯CSS实现Div高度根据自适应宽度(百分百调整)</title>

    </head>
    <style>
        .father {
            width: 100px;
            height: 100px;
            background: #222
        }
        
        .element {
            width: 50%;
            height: 0;
            padding-bottom: 50%;
            background: #eee;
        }
    </style>

    <body>
        <div class="father">
            <div class="element">
123
            </div>
        </div>
    </body>

</html>

 

posted @ 2018-04-12 13:32  生如逆旅,一苇以航  阅读(1204)  评论(0编辑  收藏  举报