<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style type="text/css"> #t1{ background-color:#f8f8f8; border-bottom:1px solid #e6e6e6; height:24px; } #t1 p{ width:900px; margin:0px auto; padding-top:5px; float:right; font-size:12px; } #t1 p a{text-decoration:none;color:#738197;} </style> </head> <body> <div id="t1"><p style="color:#0CC"> <a href="http://pc.qq.com/">苹果</a> · <a href="http://www.qq.com/">鸭梨</a> · <a href="http://im.qq.com/">鸡蛋</a> · <a href="http://im.qq.com/mobileqq/">白菜 </a> </p> </div> </body> </html>
居中的宽度是900px
#t1 p{ width:900px; margin:0px auto; padding-top:5px; font-size:12px; overflow:hidden; text-align:right; }
去掉p标签的右浮动,改为文本对齐方式为右对齐就可以了。
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <style type="text/css"> #t1{ background-color:#f8f8f8; border-bottom:1px solid #e6e6e6; height:24px; } #t1 p{ width:900px; margin:0px auto; padding-top:5px; float:right; font-size:12px; } #t1 p a{text-decoration:none;color:#738197;} </style> <div id="t1"> <p style="color: rgb(0, 204, 204); text-align: right;"> <a href="http://pc.qq.com/">苹果</a> · <a href="http://www.qq.com/">鸭梨</a> · <a href="http://im.qq.com/">鸡蛋</a> · <a href="http://im.qq.com/mobileqq/">白菜 </a> </p> </div>