当前位置:编程学习 > html/css >>

关于css背景图片调用问题

.a1,.a2,.a3{background:url(images\incp.gif) no-repeat 0 0;} .a1{width:15px;background-position:0 -2px;} .a2{width:15px;background-position:-15px -2px;} .a3{width:17px;background-position:-48px 0;} .a1{background:url(images\incp.gif) no-repeat 0 0;width:15px;background-position:0 -2px;} .a2{background:url(images\incp.gif) no-repeat 0 0;width:15px;background-position:-15px -2px;} .a3{background:url(images\incp.gif) no-repeat 0 0;width:17px;background-position:-48px 0;} 请问这2个css有什么不同?第一个对服务器的http连接数是1,第二个css是 3吗? 哪个比较好,还是一样的呢?
追问:请问,在对服务器的请求上都是一样的吗?
答案:效果是一样的,第一种写法个人感觉比较好,把公共的css都提取出来写在一起,避免代码的冗余
显示效果上两个应该是一致的。
你可以自己进行测试下看看结果是否相同。
其他:第一个好,第一个对服务器请求次数是1,第二个是2  第二个每个a标签都要对服务器请求一次,而且第一个代码相对简洁 

上一个:html嵌入php中的css问题
下一个:html中的<head>标签后写的“<link href= test2.css rel= stylesheet type= text/css />”分别代表什么意思

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,