hullamospapagaj
hullamospapagaj

Reputation: 29

Center <UL> in <DIV>

I tried many solution from stackoverflow to center my <UL> with no success. Can anyone check it?

http://mihalko.eu/index.php

I want to center "Shop 943 01 ... not available".

Thanks

Upvotes: 0

Views: 800

Answers (2)

DJafari
DJafari

Reputation: 13545

HTML :

<div class="div">
<ul>
<li>Test 1</li>
<li>Test 2</li>
<li>Test 3</li>
</ul>
</div>

CSS :

.div {
    text-align: center;
}
.div ul {
    margin: 0 auto;
}
.div ul li {
    width: 100px;
    display: inline-block;
}

Upvotes: 5

Mickel
Mickel

Reputation: 6696

If you set a fixed width on the ul you can use auto as value for the horizontal margin to center the ul.

ul {
   margin: 0 auto;
   width: 200px;
}

Upvotes: 1

Related Questions