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 }
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背景图片的位置:background的position
- CSS背景图像位置属性background-position百分比详解
- css,js实现在鼠标移动到一个位置在这个位置下面显示一个已经存在的div,这个div的位置随意
- CSS背景图像位置属性background-position百分比详解
- CSS背景图像位置属性background-position百分比详解
- css中background-image与background-color在元素背景中开始结束的位置
- css控制背景图片位置-background-position
- css切背景图片(background-position)图片精灵
- background-position—CSS设置背景图片的位置
- CSS中背景图片位置属性background-position
- (转)background-position—CSS设置背景图片的位置
- css 使用background背景实现border边框效果
- css实现网页背景图片位置不随滚动条改变
- css的那些事儿--background的多张背景的实现
- css 使用background背景实现border边框效果
- css中background:-webkit-gradient实现背景渐变效果,并且兼容各个浏览器
- JS+CSS实现几个DIV层上下移动交换位置的效果
- css实现对背景图片的定位,获得一张图片上不同位置的内容
- css背景图片位置:background的position
- css设置background图片的位置实现居中