I am building a navigation that will be used in a CMS so items may be added and removed.
The navigation is to be center aligned
I am using a list to display the menu items
The menu items need to be of a set height so I need to use display: inline-block and float left, but this then obviously makes everything display form the left.
If I used display: inline and no float left it all works correctly but then I can`t set the height of the li.
Here is my code
css
#menu-main-menu {position: relative; margin: -3px 0px 0px 0px; padding: 0px; height: 35px; font-size: 1.4em; font-weight: bold; text-align:center; list-style:none; background: #033c4e url(images/nav-background.jpg) repeat-x;}
#menu-main-menu li {display:inline-block; float: left; line-height: 35px; height: 35px; background-color: #cc0000;}
#menu-main-menu a {margin: 0px 15px 0px 15px; color: #ffffff}
html
<ul id="menu-main-menu">
<li id="menu-item-25" class="menu-item menu-item-type-post_type"><a href="/">menu 1</a></li>
<li id="menu-item-27" class="menu-item menu-item-type-post_type"><a href="/">menu 2</a></li>
<li id="menu-item-26" class="menu-item menu-item-type-post_type"><a href="/">menu 2</a></li>
<li id="menu-item-24" class="menu-item menu-item-type-post_type"><a href="/">menu 4</a></li>
</ul>
Is there a way to remain center aligned but maintain a height on the li?
The navigation is to be center aligned
I am using a list to display the menu items
The menu items need to be of a set height so I need to use display: inline-block and float left, but this then obviously makes everything display form the left.
If I used display: inline and no float left it all works correctly but then I can`t set the height of the li.
Here is my code
css
#menu-main-menu {position: relative; margin: -3px 0px 0px 0px; padding: 0px; height: 35px; font-size: 1.4em; font-weight: bold; text-align:center; list-style:none; background: #033c4e url(images/nav-background.jpg) repeat-x;}
#menu-main-menu li {display:inline-block; float: left; line-height: 35px; height: 35px; background-color: #cc0000;}
#menu-main-menu a {margin: 0px 15px 0px 15px; color: #ffffff}
html
<ul id="menu-main-menu">
<li id="menu-item-25" class="menu-item menu-item-type-post_type"><a href="/">menu 1</a></li>
<li id="menu-item-27" class="menu-item menu-item-type-post_type"><a href="/">menu 2</a></li>
<li id="menu-item-26" class="menu-item menu-item-type-post_type"><a href="/">menu 2</a></li>
<li id="menu-item-24" class="menu-item menu-item-type-post_type"><a href="/">menu 4</a></li>
</ul>
Is there a way to remain center aligned but maintain a height on the li?