<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width, initial-scale=1.0"><metahttp-equiv="X-UA-Compatible"content="ie=edge"><title>Document</title><style>div{width: 300px;height: 300px;border: 1px solid #ccc;background-image:url(./logo.png);background-repeat: no-repeat;/* 20px center 一定是x 为 20 y 是 center 等价于 background-position: 20px *//* background-position: 20px center; *//* 水平是居中对齐 垂直是 20 *//* background-position: center 20px ; *//* 当一个值的时候第二值就为center */background-position: 20px;}</style></head><body><div></div></body></html>
07-背景图片图片的固定
<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metahttp-equiv="X-UA-Compatible"content="IE=edge"><metaname="viewport"content="width=device-width, initial-scale=1.0"><title>Document</title><style>body{background-image:url(./R-C.jpg);background-repeat: no-repeat;background-position: center top;/* 把背景图片固定住 */background-attachment: fixed;color: #fff;font-size: 20px;}</style></head><body></body></html>