<!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>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-02
  • 2022-02-27
  • 2022-02-02
  • 2022-12-23
  • 2022-01-19
  • 2022-02-08
猜你喜欢
  • 2021-12-23
  • 2022-01-02
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案