Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
426 views
in Technique[技术] by (71.8m points)

html - CSS center ul list

I have this list here: 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>

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;
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...