li标签div居中方法

原文地址 http://blog.csdn.net/yxwmzouzou/article/details/17515527

一,设置li的 display:inline;就可以让其横向展示。

二,设置上一层DIV的text-align:center;

 

今天碰到一个很想解决的问题,又解决不了的问题,正好有人和我一样,高手帮他解决了,

让ul在一个div中居中显示,li浮动后ul就整个靠左了。
后来在高手的帮助下终于搞定了代码如下:
<style>
.box{border:1px solid #000000;width:800px;margin:auto;}
ul,li{margin:0px;padding:0px;}
.box ul li{border:1px solid #333333;background:#CCCCCC;color:#000000;/*width:60px;*/text-align:center;
/*float:left;*/margin-right:5px; list-style:none}
        
.box {*text-align:center;}
ul {display:table;margin-left:auto;margin-right:auto;}
ul li{float:left;*float:none;*display:inline;*zoom:1;}
</style>
<div class="box">
     <ul>
         <li>12313</li>
         <li>by jubdit</li>
         <li>12313</li>
     </ul>
   <br clear="left" />
</div>

posted @ 2016-06-03 19:25  pro-pro  阅读(1065)  评论(0)    收藏  举报