6_等比缩放.html 434 B

12345678910111213141516171819
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. <style>
  8. .box{
  9. max-width: 800px;
  10. background-color: red;
  11. /* padding 的100% 是相对于自身的宽度 */
  12. padding-top: 50%;
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <div class="box"></div>
  18. </body>
  19. </html>