练习仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.5 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
.bac{
width: 500px;
height: 510px;
background-color: green;
background-image: url("1.webp");
/* 平铺方式:
repeat:默认方式;
repeat-x:只水平平铺
repeat-y:只垂直平铺
no-repeat:不平铺
*/
background-repeat: repeat-x;
/* length:只调整高或宽,另一个值等比例改变
percentage:设定百分比
cover:锁定比例并且充满容器,多余部分不显示
contain:锁定比例且保证图片最大 */
background-size: 500px;
}
.bac2{
width: 1000px;
height: 1100px;
background-color: green;
background-image: url("2.webp");
background-repeat: no-repeat;
background-size: contain;
}
.bac3{
width: 200px;
height: 100px;
background-color: green;
background-image: url("2.webp");
background-repeat: no-repeat;
/* 用left,right,top,bottom组合确定图像起始位置
x% y%:只设置一个另一个默认为50%。 都不设置默认为0% 0%;
xpos ypos:像素表示 */
background-position: left center;
}
</style>
<body>
<div class="bac"></div>
<div class="bac2"></div>
<div class="bac3"></div>
</body>
</html>