您的位置:首页 > Web前端 > CSS

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

2017-10-29 20:58 459 查看
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 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  css