3

I've been trying/searching for a while, but I can't make it work.

<div class="wrapper">
    <div class="project-container">
        <ul>
            <li><div class="project-box"></div></li>
            <li><div class="project-box"></div></li>
            <li><div class="project-box"></div></li>
        </ul>
    </div>
</div>

I managed to center floated elements (like in here http://jsfiddle.net/z7pqP/2/) following this explanation (http://solstice.co.il/blog/2008-02-26/horizontally-centering-content-dynamic-width-css).

However, if the floated elements must occupy more than one line, because they don't fit in a single line, (when there are more than 9 'li', for example, or when the window gets stretched), they are no longer centered.

Edit: I want it to be responsive, not a fixed width.

How could I keep multiline floated elements centered? Any other suggestion/better way to make a flexible width/responsive grid?

David Da Silva Contín
  • 1,051
  • 2
  • 10
  • 20
  • Like this? http://jsfiddle.net/z7pqP/3/ – Kevin Boucher May 07 '13 at 21:38
  • I should have been more specific. I want it to be responsive, not a fixed width. If an element has to go down to the following row/line because it doesn't fit the current one, it should go down. – David Da Silva Contín May 07 '13 at 21:44
  • Okay, I think I've finally found the answer, but the items are not floated anymore... I'm going to try it. http://stackoverflow.com/questions/3913383/multiple-centered-floating-divs-in-a-liquid-layout?rq=1 – David Da Silva Contín May 07 '13 at 21:46