
CSS 基础知识,高手请绕边。如上所示,要实现图片的鼠标 hover 事件,一般是为图片链接添加hover后的图片。如上图的 YouTube 标志效果。在图片的制作中一般要为每个图片链接添加两张图片,5个链接就要10张图片,这不仅细微的拖慢了页面的加载速度,在制作过程中也会有诸多不便,如图片的对齐问题,而将图片背景的集中处理是个很好的解决方案。
以上的效果背景图片为:
![]()
关键性的代码:
icon a{width:20px; height:20px; padding:0; background:url(social-icons.png) no-repeat;text-indent:-9999px; overflow:hidden;}
icon a:hover{background-position:0 -22px;}
twitter a{background-position:-20px 0;}
twitter a:hover{background-position:-20px -22px;}
flickr a{background-position:-40px 0;}
flickr a:hover{background-position:-40px -22px;}
facebook a{background-position:-60px 0;}
facebook a:hover{background-position:-60px -22px;}
. . . . . .
关键的代码在于对 background-position 这个属性的操作,每个按钮对应不同的背景图片相应位置。
网站地址: Android and Me
路过看到不错有想法http://www.8net8.net/
很有体会啊http://www.8net8.net/
呵呵,佩服
灰机灰过
我要让笑容成为自己的招牌动作
学习了
管用!
低调的飘过
我轻轻的走了,正如我轻轻的来
很强大,支持下