页面水平导航菜单在符动的情况下也能随内容多少自适应居中啦!
<!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" /> <style type="text/css"> ul{margin:0;padding:0;list-style:none;} #nav{font-family:Verdana,Arial,sans-serif;font-size:12px;margin:120px auto;padding:0;text-align:center;} #nav ul{display:inline-block;*display:inline;*zoom:1;border:solid 1px red;padding:10px;} #nav li{height:30px;float:left;} #nav li a{float:left;height:30px;line-height:30px;padding:0 23px;background:#97C099;} #nav li a:hover{background:#59c099;color:#fff;} </style> <title>float菜单局中法</title> </head> <body> <div id="nav"> <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> </ul> </div> </body> </html>