Google Custom Search
Google
Web CSS Forest FAQ
CSS Forest FAQ > 问与答 > 问个关于背景的问题
disconnected

问个关于背景的问题

... by 冰剑 ... 8 27 天前 ... 383次点击
说不清楚是什么,大家看我下面的举例吧!

如果一个css文件用的是css sprite,里面的所有图片都是在一个文件上的!
你们是把所都定义在一起然后background-position,还是每个样式都background:url(images/pic.png) no-repeat 0 0;

第一种例如:
.div1 ,
.div2,
h1,h2, {background:url(images/pic.png) no-repeat 0 0;}

然后在下面需要的时候再:
.div1 {background-position:0 -100px;}
.div2 {background-position:0 -300px;}
h1 {background-position:0 -400px;}
h2 {background-position:0 -500px;}

还是第二种:

.div1 {background:url(images/pic.png) no-repeat 0 -100px;}
.div2 {background:url(images/pic.png) no-repeat 0 -300px;}
h1 {background:url(images/pic.png) no-repeat 0 -400px;}
h2 {background:url(images/pic.png) no-repeat 0 -500px;}


你是用第一种还是第二种呢?为什么?
还是有第三种的也可以探讨!
2篇回复 | 回到顶部 | 回复主题
  chenkjia
1 - 8 27 天前
第三种方式:
上面用background-images:;background-repeat:;
下面用backgorund-position:;
  Ghostzhang
2 - 6 4 天前
第一种我用得比较多,有时会用第三种。
看完之后有话想说?那就帮楼主加盖一层吧!
在回复之前你需要先进行登录
昵称
密码