三、CSS常用的属性
(三)、背景属性
5、背景属性
属性名 | 描述 | 属性值 |
---|---|---|
background-color | 背景图片 | 3种值,常用十六进制 |
background-image | 背景图片 | url地址,如:url:(./xxx.jpg); |
background-repeat | 背景平铺方式 | no-repeat(不平铺),用于导航、repeat-x(X轴平铺)、repeat-y(Y轴平铺) |
background-position | 背景定位 | X轴定位和Y轴定位,如:position:left top;设置左右和上下 |
定位方式:
1、单词定位方式:left|center|right top|center|bottom单词定位可以理解一个九宫格。
left top | center top | right top |
---|---|---|
left center | center center | right center |
left bottom | center bottom | right bottom |
2、 像素定位方式:像素只有离左和离上
background-position:50px 100px /*离左边50像素,离上面100像素*/
3、百分比定位方式:
background-positon:10% 20% /*离左边百分之10,离上面百分20*/
4、混合定位方式:
background-position:center 100px /*中间离上面100像素*/
背景属性
属性名 | 描述 | 属性值 |
---|---|---|
background-attachment | 背景固定 | scroll(滚动-默认)、fixed(固定) |
background | 简写形式 | 颜色、图片、平铺方式、定位、固定,其中的选项可以没有 |
网友评论