Note that there are some explanatory texts on larger screens.

plurals
  1. POCenter a menu with left align items
    primarykey
    data
    text
    <p>I need to design a menu, in which the menu is always centered, with variable number of items, browser resolutions, and the items would be aligned to the left (menu centered in the page, but items aligned to the left).</p> <p><a href="http://i39.tinypic.com/2vx0ha9.jpg" rel="nofollow noreferrer">http://i39.tinypic.com/2vx0ha9.jpg</a></p> <p>(As you can see it is not centered at all).</p> <p>This is my code:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; .extPanel{ background-color:#555; padding: 0px 20% 0px 20%; display: table; } .split{ clear: both; } .menuElement{ float:left; background-color:#aaa; margin: 0px 20px 20px 0px; width: 200px; height: 200px; text-align: center; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="extPanel"&gt; &lt;div class="menuElement"&gt;item1&lt;/div&gt; &lt;div class="menuElement"&gt;item2&lt;/div&gt; &lt;div class="menuElement"&gt;item3&lt;/div&gt; &lt;div class="menuElement"&gt;item4&lt;/div&gt; &lt;div class="split"&gt;&lt;/div&gt; External Panel. 20% left and right padding. &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>As you can see, the external div has 20% padding in order to center the items. Items float to the left. Items are not centered at all because a remaining space exists in which item4 doesn't have enough space, so it floats to the next line. </p> <p>And if the menu would have only one menu item, this item float to left so is more obvious that the menu is not centered. If I try to use some style to center all the items (text-align or something like this), item4 would appear centered below item2, and I need that the items are align to left.</p> <p>I need:</p> <ul> <li>Menu to be centered in the page, with any number of items </li> <li>Items centered </li> <li>Cross-browser compatibility (to IE8 at least, and mobile explorers) </li> <li>No JavaScript</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload