我们看下面的xhtml代码:
<div id="links">
<ul>
<li><a href="#" title="CSS Web Design">CSS Web Design<em>xhtml+css div+css - webjx.com</em> <span>www.webjx.com</span></a></li>
<li><a href="#" title="CSS Web Design">CSS Web Design<em>xhtml+css div+css - webjx.com</em> <span>www.webjx.com</span></a></li>
</ul>
</div>
我们对上面的xhtml编写css代码:
#links ul {
list-style-type: none;
width: 280px;
}
#links li {
border: 1px dotted #06f;
border-width: 1px 0;
margin-bottom: 16px;
}
#links li a {
color: #00f;
display: block;
font: bold 120% Arial, Helvetica, sans-serif;
padding: 8px;
text-decoration: none;
}
* html #links li a { /* make hover effect work in IE */
width: 280px;
}
#links li a:hover {
background: #f0f0f0; color:#036;
}
#links a em {
color: #666;
display: block;
font: normal 85% Verdana, Helvetica, sans-serif;
line-height: 125%;
}
#links a span {
color: #999;
font: normal 70% Verdana, Helvetica, sans-serif;
line-height: 150%;
}
我们看最终的运行效果:
<!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=utf-8" />
<title>www.webjx.com</title>
<style type="text/css">
#links ul {
list-style-type: none;
width: 280px;
}
#links li {
border: 1px dotted #06f;
border-width: 1px 0;
margin-bottom: 16px;
}
#links li a {
color: #00f;
display: block;
font: bold 120% Arial, Helvetica, sans-serif;
padding: 8px;
text-decoration: none;
}
* html #links li a { /* make hover effect work in IE */
width: 280px;
}
#links li a:hover {
background: #f0f0f0; color:#036;
}
#links a em {
color: #666;
display: block;
font: normal 85% Verdana, Helvetica, sans-serif;
line-height: 125%;
}
#links a span {
color: #999;
font: normal 70% Verdana, Helvetica, sans-serif;
line-height: 150%;
}
</style>
</head>
<body>
<div id="links">
<ul>
<li><a href="#" title="CSS Web Design">CSS Web Design<em>xhtml+css div+css - webjx.com</em> <span>www.webjx.com</span></a></li>
<li><a href="#" title="CSS Web Design">CSS Web Design<em>xhtml+css div+css - webjx.com</em> <span>www.webjx.com</span></a></li>
</ul>
</div>
</body>
</html>