CSS 背景background,精灵spirit(移动背景图位置来实现)

来源:互联网 发布:网络文学作品排行榜 编辑:程序博客网 时间:2024/06/05 22:32
CSS背景background
background-color:
背景色,英文单词或十六进制颜色都可以。
background-image:url(图片路径)背景图
background-repeat:(no-repeat不重复,repeat-x,repeat-y)重复

background-position:(left,center top bottom right) 背景图定位。(left top 表示左上角。right bottom 表示右下角。center 中间。left 20px 表示左边,向下移动20像素。 -30px -20px 表示向左移动30px,向上移动20px (spirit精灵就是通过移动背景图(大的背景图中有很多小的图)的位置来实现的,通常都是负数))

如:a{ width:110px;height: 40px;background:url(bg1.png) no-repeat -20px -50px; display:block;}    /* <a>标签是行内元素,width和height属性不起作用。加上display:block; 指定为块元素,width和height属性才会生效 */

background-attachment: (依附方式)是否固定,fixed
如: .box{background:#ccc url(图片的路径) no-repeat 定位坐标 fixed }



原创粉丝点击