<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><title>背景</title><styletype="text/css">div{width: 400px;height: 500px;background-color: purple;background-image:url(btn.png);background-repeat: no-repeat;不平铺
background-position: x y; top bottom left right center
background-position: center center;/* background-position :
1、后可跟方位名词,没有先后顺序;
2、如果只写一个方位名词,另一个默认值是居中center;
3、后也可跟 值px;但是必须有顺序,即第一个参数是x,第二个参数是y */background-position: bottom;background-position: left;background-position: 12px 50px;background-position: 50px 12px;background-position: 10px center;background-attachment: fixed;/* background: 背景颜色 背景图片地址 背景平铺 背景滚动 背景位置 *//* background: #000 url(btn.png) no-repeat fixed center top; */}</style></head><body><div></div></body></html>
二、背景半透明
<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><title>Document</title><styletype="text/css">body{background-color: pink;}div{width: 200px;height: 200px;/* background-color: #000; */color: #fff;background-color:rgba(0,0,0,0.3);/* red green blue alpha(透明度) */}</style></head><body><div>文字内容</div></body></html>