8、CSS背景使用实例演练

时间:2021-03-09 13:13:25   收藏:0   阅读:0

CSS背景使用实例演练

下面介绍和背景相关的css属性,背景是所有的标签都具有的css属性。



背景有以下几种常用属性:

(1) 背景颜色

background-color:颜色

(2) 背景图片

background-image:url( ‘ ’ )

(3) 背景重复方式

background-repeat:重复方式

① background-repeat:repeat          平铺(系统默认方式)

这个属性如果不设置,系统会默认为repeat(平铺),效果如上面的图片,这里不在重复笔墨。

② background-repeat:repeat-x          沿着x轴平铺

③ background-repeat:repeat-y          沿着y轴平铺

④ background-repeat:no-repeat          不平铺

(4) 背景附着方式

background-attachment:附着方式

background-attachment:fixed          固定

(5) 背景位置

background-position:x y

① background-position:?px ?px          实际坐标

② background-position:?% ?%          百分比

③ background-position:left/center/right top/center/bottom          方位词

(6) 背景属性整合

background:color image repeat attachment position

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!