背景属性:
background-color 背景颜色
background-image 背景图片
背景重复:
background-repeat: repeat/no-repeat/repeat-x/repeat-y
背景位置:background-position:
position: x y:
? 像素:100px 100px
? 百分比:10% 20%: (容器宽度-图片宽度)*10%
? left center right, top center bottom;
? -100px,0px
background-attachment: 背景跟随内容滚动或者固定
background-attachment:fixed;
background-attachment:scroll;
复合写法:
background: url("./img/2.jpg") center top no-repeat scroll;
.html
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>背景2</title> 6 <link rel="stylesheet" href="./bg2.css"> 7 </head> 8 <body style="height: 2000px;"> 9 <p>0</p> 10 <p>1</p> 11 </body> 12 </html>
.css
body {
background: #fff url("http://real2.s-angels.com/images/sample/m254_misa/thumb/model_top.jpg") center top no-repeat fixed;
}
原文地址:https://www.cnblogs.com/denggelin/p/8995022.html
时间: 2024-10-10 08:13:42