

代码如下:
HTML代码:
复制代码代码如下:
<a id="theLink"></a>
CSS代码:
复制代码代码如下:
#theLink{
display:block;/*因为标签a是内链元素,所以利用这句话将内链元素转化成块状元素,后面的width和height才起作用*/
width:120px;
height:41px;
margin:0 auto;
background:url(../images/normal.gif) no-repeat;
}
#theLink:hover{background:url(../images/press.gif) no-repeat;}
这节课,主要给大家介绍第二种思路,其实也很简单,首先我们将上面的两个图片合并成一张图片,如下 
其次,将上面的图片设置成按钮的背景
最后,将a:hover的背景向上移动41个像素就OK了
HTML代码:
复制代码代码如下:
<a id="buttonBlock"></a>
CSS代码:
复制代码代码如下:
#theLink{
display:block;
width:120px;
height:41px;
margin:0 auto;
background:url(../images/buttonBG.gif) no-repeat;
}
#theLink:hover{ background:url(../images/buttonBG.gif) no-repeat 0 -41px;}
可能我讲到这里,你不能完全理解,没关系
下载下来源代码,保你一看就明白
实例打包下载