admin 发表于 2022-9-15 20:29:59

DIV里面的li 水平居中代码分享

网站制作中,我们在制作导航的时候,经常会遇到 多个并排LI需要页面居中显示,效果入下图

这个时候text-align:center是无效的
下面列数实际可以用的代码:
<style>
.box
{
    width:90%;
    margin:auto;
}
.box ul
{
    display:table;/**不要设置宽度*/
    margin:10px auto;
}
.box ul li
{
    border:1px solid #06C;
    text-align:center;
    float:left;
    *float:none;
    *display:inline;
    *zoom:1; list-style: none;
        padding:10px;
        margin:10px;
        width:10%;
        background:#06C;
}
.box ul li a{ color:#fff}
</style>以上就是宝葫芦整理的div中li水平居中代码,拿去不谢!!!!
页: [1]
查看完整版本: DIV里面的li 水平居中代码分享