<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
/* body { background: url(./assets/airpods.png) no-repeat; background-size: 100% 100%;} */div { width: 500px; height: 500px; border: 2px solid red; background: url(./images/dog.jpg) no-repeat; /* background: url(./assets/airpods.png) no-repeat; */ /* background-size: 500px 200px; */ /* 1.只写一个参数 必定是宽度 高度省略 这时会等比例缩放 */ /* background-size: 500px; */ /* 2.外面能够跟% 绝对与父盒子来说 */ /* background-size: 50%; */ /* background-size: 100% 100%; */ /* 3. cover 要齐全笼罩div盒子 可能有局部背景图片显示不全 */ /* background-size: cover; */ /* 4. contain 高度和宽度等比例拉伸 当宽度或者高度铺满div盒子时 不再拉伸 可能有局部空白区域 */ background-size: contain;}
</style>
</head>
<body>
<div></div>
</body>
</html>