CSS实例:用CSS实现hover悬停时链接文字产生阴影
在前面,我们说过了链接文字的下划线的一些情况,现在我们考虑如何实现链接文字产生阴影?当鼠标移到链接文字上时,链接文字可以改变颜色,并产生一定的阴影而营造出立体效果,一定比较引人注目。
链接文字阴影效果CSS代码:
ul,li{ margin:0px; padding:0px; list-style-type: none;}
#nav{font-family: Verdana, "宋体", Arial;}
#nav li{ float:left; margin-left:30px;}
#nav span{display:none;}
#nav a{font-size:12px; font-weight:800; color:#c00; text-decoration:none; display:block;}
#nav a:hover{ color:#999;top:1px; left:1px; position:relative;}
#nav a:hover span{ display:block; top:-1px; left:-2px; position:absolute; color:#000; cursor:pointer;}
链接文字阴影效果XHTML代码:
<div id="nav">
<ul>
<li><a href="CuoXin.Com">Div+CSS教程<span>Div+CSS教程</span></a></li>
<li><a href="CSS">">CSS布局实例<span>CSS布局实例</span></a></li>
<li><a href="CSS2.0">">CSS2.0教程<span>CSS2.0教程</span></a></li>
<li><a href="CSS">">CSS在线手册<span>CSS在线手册</span></a></li>
<li><a href="Web">">Web标准<span>Web标准</span></a></li>
<li><a href="XHTML">">XHTML教程<span>XHTML教程</span></a></li>
</ul>
</div>
链接文字阴影效果实例:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
<!--
ul,li{ margin:0px; padding:0px; list-style-type: none;}
#nav{font-family: Verdana, "宋体", Arial;}
#nav li{ float:left; margin-left:30px;}
#nav span{display:none;}
#nav a{font-size:12px; font-weight:800; color:#c00; text-decoration:none; display:block;}
#nav a:hover{ color:#999;top:1px; left:1px; position:relative;}
#nav a:hover span{ display:block; top:-1px; left:-2px; position:absolute; color:#000; cursor:pointer;}
-->
</style>
</head>
<body>
<div id="nav">
<ul>
<li><a href="CuoXin.Com">Div+CSS教程<span>Div+CSS教程</span></a></li>
<li><a href="CSS">">CSS布局实例<span>CSS布局实例</span></a></li>
<li><a href="CSS2.0">">CSS2.0教程<span>CSS2.0教程</span></a></li>
<li><a href="CSS">">CSS在线手册<span>CSS在线手册</span></a></li>
<li><a href="Web">">Web标准<span>Web标准</span></a></li>
<li><a href="XHTML">">XHTML教程<span>XHTML教程</span></a></li>
</ul>
</div>
</body>
</html>