比如,这个案例里的,这是图片文件夹里的,在css里插入左半边图的时,要怎么操作?
这是作者代码,我看不懂,求解
.login_logo_webqq {
background: url('../images/login_window_logo.png') no-repeat -210px -0px;
margin-left: 100px;
margin-top: 10px;
width: 200px;
height: 44px;
cursor: move;
}
这就是常说的雪碧图方法了,简单来说就是插入一张较大的背景图,然后使用参数限定背景图中的某一部分显示在元素背景上。
background: url('../images/login_window_logo.png') no-repeat -210px -0px;
这条语句的意思是:
插入背景图:../images/login_window_logo.png;
不重复显示该背景:no-repeat
-210px -0px:从背景图的-210px -0px;坐标开始,截取背景图中大小为width: 200px;height: 44px;的一部分作为该元素的背景
可以理解为,我们虽然加载了一张大图,但是只使用其中的一部分
这样的好处是,一次性加载包含很多图片的大图,通过该方法每次使用图片中一部分,减少了服务器请求次数,降低服务器载荷。
#close{
background: url("../images/boxy_btn.png") no-repeat;
width:28px;
height:28px;
float: right;
margin-right: -10px;
margin-top: -10px;
cursor: pointer;
}
这个代码里,我把width和height去掉,背景图就显示不出来了,能解释一下吗
-210px -0px,这部分的相对原点是哪里?