怎样保持div中的子元素的长宽比例展示

<!DOCTYPE html>
<html>
 <head> 
  <meta charset="utf-8" /> 
  <title>菜鸟教程(runoob.com)</title> 
  <style>
        .container {
        height: 0;
  padding: 20%;
  position: relative;
        }
        .container div{
            border: 2px solid #dddddd;
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  width: 100%;
        }
    </style> 
 </head> 
 <body> 
  <div class="container"> 
   <div class="">
     aaaa 
   </div> 
  </div>  
 </body>
</html>

 

菜鸟教程(runoob.com)

aaaa
posted @ 2020-08-03 17:50  上官靖宇  阅读(239)  评论(0编辑  收藏  举报