Home >Web Front-end >HTML Tutorial >About web page a:hover problem_html/css_WEB-ITnose
The effect I have now is like this
But the effect I want now is like this
The CSS code is as follows
[img=http:/
a{ color:#FFFFFF; text-decoration:none;} a:hover{ background-color:#F71469; text-decoration:none;background-image:none;} .mainNav{background:#ff478c; font-size:18px; height:45px; line-height:12px; overflow:hidden;} .mainNav ul{list-style:none; list-style-position:outside; list-style-image:none;} .mainNav ul li{ float:left;} .mainNav ul li a{padding:0 30px; text-decoration:none; text-align:center;}
<body> <div class="mainNav"> <ul> <li><a href="#">首页</a></li> <li><a href="#">服装秀</a></li> <li><a href="#">美容</a></li> <li><a href="#">奢侈品</a></li> <li><a href="#">男人帮</a></li> <li><a href="#">尚风</a></li> <li><a href="#">尚娱</a></li> <li><a href="#">瘦身</a></li> <li><a href="#">星座</a></li> </ul> </div></body>
<!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>无标题文档</title><style> a{ color:#FFFFFF; text-decoration:none;} a:hover{ background-color:#F71469; text-decoration:none;background-image:none;} .mainNav{background:#ff478c; font-size:18px; height:45px; overflow:hidden;padding-left:20px;} .mainNav ul{list-style:none; list-style-position:outside; list-style-image:none; margin:0;padding:0;} .mainNav ul li{ float:left;} .mainNav ul li a{padding:0 30px; text-decoration:none; text-align:center; display:block;line-height:45px;height:45px;}</style></head><body><div class="mainNav"> <ul> <li><a href="#">首页</a></li> <li><a href="#">服装秀</a></li> <li><a href="#">美容</a></li> <li><a href="#">奢侈品</a></li> <li><a href="#">男人帮</a></li> <li><a href="#">尚风</a></li> <li><a href="#">尚娱</a></li> <li><a href="#">瘦身</a></li> <li><a href="#">星座</a></li> </ul> </div></body></html>