仿163邮箱的按钮效果
- 2007-11-17
- 分类:XHTML+CSS
- 作者:银子
- 282 次查看
163邮箱是用JS来实现的,我这里用到了CSS伪类 hover
Demo http://www.qqdang.net/code/mail163/
HTML
- <!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>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <title>163邮箱按钮</title>
- <link href="style.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="top">
- <div id="logo"><img src="163logo.gif" alt="logo" /></div>
- </div>
- <div id="nav">
- <ul>
- <li><a href="#"><span class="left"></span><span class="center">发送</span><span class="right"></span></a><span class="img1"></span></li>
- <li><a href="#"><span class="left"></span><span class="center">存草稿</span><span class="right"></span></a><span class="img2"></span></li>
- <li><a href="#"><span class="left"></span><span class="center">贺卡</span><span class="right"></span></a><span class="img3"></span></li>
- <li><a href="#"><span class="left"></span><span class="center">查词典</span><span class="right"></span></a><span class="img4"></span></li>
- </ul>
- </div>
- </body>
- </html>
CSS
- * {
- margin:0;
- padding:0;
- font-size:12px;
- }
- #top {
- height:91px;
- background:url(f2.gif) repeat-x;
- }
- #logo {
- padding:6px;
- }
- #nav {
- height:37px;
- width:100%;
- background:url(f2.gif) repeat-x 0px -147px;
- }
- #nav ul {
- list-style:none;
- float:left;
- margin-top:4px;
- }
- #nav li {
- float:left;
- margin:0 6px;
- }
- #nav li a {
- display:block;
- height:26px;
- text-decoration:none;
- color:#444;
- cursor:pointer;
- }
- #nav li a span.center{
- height:26px;
- float:left;
- padding:6px 3px 0 28px;
- *padding:7px 3px 0 28px;
- width:100%;
- }
- #nav li a:hover span.center{
- background:url(f2.gif) repeat-x 0px -250px;
- }
- #nav li a span.left {
- float:left;
- width:5px;
- height:26px;
- }
- #nav li a:hover span.left {
- background:url(f1.gif) no-repeat -757px -16px;
- }
- #nav li a span.right {
- float:left;
- width:5px;
- height:26px;
- }
- #nav li a:hover span.right {
- background:url(f1.gif) no-repeat -781px -16px;
- }
- #nav li span.img1 {
- width:26px;
- height:13px;
- display:block;
- background:url(ico.gif) no-repeat -1318px -42px;
- position:relative;
- left:5px;
- bottom:20px;
- }
- #nav li span.img2 {
- width:14px;
- height:13px;
- display:block;
- background:url(ico.gif) no-repeat -1360px -42px;
- position:relative;
- left:8px;
- bottom:20px;
- }
- #nav li span.img3 {
- width:26px;
- height:13px;
- display:block;
- background:url(ico.gif) no-repeat -1393px -42px;
- position:relative;
- left:5px;
- bottom:20px;
- }
- #nav li span.img4 {
- width:17px;
- height:13px;
- display:block;
- background:url(ico.gif) no-repeat -1434px -42px;
- position:relative;
- left:8px;
- bottom:20px;
- }

