Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I center my ul li list in css?

Tags:

html

css

I have the following html code:

<section class="video">
            <div class="container">
                <div class="row">
                    <div class="col-md-12 text-center">

                        <ul class="footer-nav">
                            <li><a href="#">Contact</a></li>
                            <li><a href="#">Press</a></li>
                            <li><a href="#">Careers</a></li>
                            <li><a href="#">Business</a></li>
                            <li><a href="#">Careers</a></li>
                            <li><a href="#">Business</a></li>
                        </ul>

                    </div>
                </div>
            </div>
        </section>

and with my CSS included (in the jsfiddle) I get the result that the text is aligned to the left... How can I center everything, so the result says:

                  Contact  Press  Careers  Business  Careers  Bussiness 

? Thanks.

like image 601
randomuser1 Avatar asked Jun 14 '15 13:06

randomuser1


2 Answers

http://jsfiddle.net/tfLz08vd/2/

just add

ul {
text-align: center;
}

li {
display: inline-block;
}

Good luck! ;)

like image 172
Matej Đaković Avatar answered Sep 20 '22 15:09

Matej Đaković


Similar question added few time ago How do I get my <.li> centered in my nav

You simply have to add text-align: center to ul element like this:

.footer-nav{
    text-align: center;
}

.footer-nav li {
    list-style: none;
    padding: 5px;
    display: inline-block;
}
like image 32
Tiziano Mischi Avatar answered Sep 19 '22 15:09

Tiziano Mischi