Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aligning <li> next to each other, not working

I have a problem with aligment of two li elements inside a div because in the next example

HTML

<div id="menu-container">
    <div class="menu-left">
        <ul id="menu-principal" class="menu">
            <li><a href="">Hola</a></li>
            <li><a href="">Hola2</a></li>
        </ul>
    </div>
<!-- More code -->
</div>

The CSS code is in the next link and I use that html structure because that is what is generated by placing a menu in wordpress.

http://jsfiddle.net/Soldier/KhLhR/1/

I have a simple code with two li elements and I want to align horizontally with 50% of width for each but doesn't work.

Edit

Well.. All responses involve float: left, but did not want to use float: left because this causes overflow to ul and I have to use overflow: hidden .. I thought there was another factor that was failing but they all give +1 and accept the answer that answered first.

Thanks

like image 728
SoldierCorp Avatar asked Apr 29 '13 18:04

SoldierCorp


People also ask

How do you put two UL next to each other?

Wrap each ul into a parent div and apply display: inline-block; and vertical-align: top; to them.

How do you align things next to each other in HTML?

With CSS properties, you can easily put two <div> next to each other in HTML. Use the CSS property float to achieve this. With that, add height:100px and set margin.

How do I align content side by side?

Use CSS property to set the height and width of div and use display property to place div in side-by-side format. float:left; This property is used for those elements(div) that will float on left side. float:right; This property is used for those elements(div) that will float on right side.


1 Answers

Add a left float to your li elements:

.menu-left ul li {
    display:inline-block;
    vertical-align: top;
    width: 50%;
    float: left;
}
like image 196
Tombala Avatar answered Oct 19 '22 12:10

Tombala