CSS中心ul列表 [英] CSS center ul list

查看:136
本文介绍了CSS中心ul列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在此列出此列表: jsfiddle

<div class="footer-location">
    <ul>
        <li>123 Fake St.</li>
        <li>Toronto, Ontario, Y1Y 1Y1</li>
        <li>416-555-5555</li>
        <li><a href="mailto:info@email.com">info@email.com</a></li>
    </ul>
</div>

我试图集中整个列表,我尝试设置宽度和设置边距为0 auto ,但它没有做任何事情,这里是我的css代码:

And I am trying to center the whole list, I tried setting a width and set margin to 0 auto, but it did't do anything, here is my css code:

.footer-location {
    float: left;
    width: 100%;
    padding-right: 20px;
    padding-left: 25px;
    margin: 0 auto;
    text-align: center;
}

.footer-location ul {
    list-style: none;
}

.footer-location ul li {
    color: #808080;
    padding-bottom: 3px;
    font-size: 12px;
    font-family: Arial, Helvetica, sans-serif;
    float: left;
    padding-right: 10px;
}


推荐答案

> .footer-location ul li 使用 display:inline-block; 而不是 float:left;

on .footer-location ul li use display:inline-block; instead of float:left;

.footer-location ul li {
display:inline-block;
color: #808080;
padding-bottom: 3px;
font-size: 12px;
font-family: Arial, Helvetica, sans-serif;
padding-right: 10px;
}

DEMO: http://jsfiddle.net/pfW2v/2/

这篇关于CSS中心ul列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆