一张背景图实现的漂亮黄色CSS菜单

代码简介:只用一张背景图实现的CSS菜单,但是效果确实非常好,不便可以使用,而且对学习CSS控制背景平铺很有帮助,一张图可以省去我们很多麻烦,推荐使用本种方法控制背景类的图片等。

代码内容:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>一张背景图实现的漂亮黄色CSS菜单_网页代码站(www.webdm.cn)</title>
<style>
ul,li{ list-style:none; float:left;}
body{ font-size:12px; line-height:1.6; font-family:Verdana; text-align:center;}
#info li{ margin-left:4px; margin-top:15px;}
#info a {display:block;text-align:center; padding-left:15px;
padding-top:2px;padding-bottom:1px;background-image: 
url(http://www.webdm.cn/images/20090915/mbgs.GIF);
background-repeat: no-repeat;47px; cursor:hand; text-decoration: none;}
#job a:link,#job a:visited{background-position: -62px 0px;}
#eve a:link,#eve a:visited{background-position: -124px 0px;}
#oth a:link,#oth a:visited{background-position: -186px 0px;}
#car a:hover ,#car a:active {background-position: 0px -22px; color:#fff;}
#job a:hover ,#car a:active {background-position: -62px -22px; color:#fff;}
#eve a:hover ,#car a:active {background-position: -124px -22px; color:#fff;}
#oth a:hover ,#car a:active {background-position: -186px -22px; color:#fff;}
</style>
</head>

<body> 
<div id="info">
<ul>
<li id="car"><a href="/" target="_blank"><span>主 页</span></a></li>
<li id="job"><a href="http://www.webdm.cn" target="_blank"><span>源 码</span></a></li>
<li id="eve"><a href="http://www.webdm.cn" target="_blank"><span>特 效</span></a></li>
<li id="oth"><a href="/" target="_blank"><span>音 乐</span></a></li>   
</ul> 
</div>
</body>
</html>
<br>
<p><a href="http://www.webdm.cn">网页代码站</a> - 最专业的代码下载网站 - 致力为中国站长提供有质量的代码!</p>

代码来自:http://www.webdm.cn/webcode/8ed297bc-a67a-47e8-beea-1f37736a41e9.html

原文地址:https://www.cnblogs.com/webdm/p/1959521.html