CSS背景图片布局
作者:Kinglong
发表时间:2023-07-16 07:33
关键词:
背景图片语法:
background-image:url() 引入背景图片
background-repeat:no-repeat 设置背景图片是否重复平铺
background-position:left top 设置图片的css背景定位,left代表靠左,top代表靠上
简写背景图片语法:
background:url(图片地址) no-repeat left top
1、背景图片左上角
body{background:url(imgurl) no-repeat 0 0 }
2、背景图片横向居中
body{background:url(imgurl) no-repeat center top}
3、背景图片靠左纵向居中
body{background:url(imgurl) no-repeat left 50%}
4、背景图片页面居中
body{background:url(imgurl) no-repeat center 50%}
5、背景图片横向平铺
body{background:url(imgurl) repeat-x}
6、背景图片纵向平铺
body{background:url(imgurl) repeat-y}
7、全网页背景图片重复平铺
body{background:url(imgurl)}