| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <style>
- .box {
- /* width: 600px; */
- max-width: 600px;
- margin: 100px auto;
- }
- .box img {
- width: 100%;
- }
- .box2 {
- max-width: 600px;
- margin: 0 auto;
- }
- .box3 {
- background-image: url(./img/img1.jpg);
- background-size: cover;
- width: 100%;
- /* padding 使用百分比 相较于父元素的宽度 */
- padding-top:62.5%;
- }
- </style>
- </head>
- <body>
- <div class="box">
- <img src="./img/img1.jpg" alt="">
- </div>
- <div class="box2">
- <div class="box3"></div>
- </div>
- </body>
- </html>
|