[EDIT]
I'm looking for a solution without javascript, and without medias queries (user can change the container size).
[/EDIT]
I need to create a grid of items.
- The container has a flexible width.
- The grid is always centered
- Items inside the grid need to be left aligned
Pretty simple, but I can't find the solution !!
Here is an image that present what I need:
And here is a jsfiddle : http://jsfiddle.net/5e4bcc9L/1/
HTML :
<div class="container">
<div class="grid">
<a href="#"></a>
<a href="#"></a>
<a href="#"></a>
<a href="#"></a>
<a href="#"></a>
<a href="#"></a>
<a href="#"></a>
</div>
</div>
CSS :
.container {
width: 100%;
background-color:#CCC;
text-align: center;
}
.grid {
background-color:#999;
display: inline-block;
text-align: left;
}
a {
display:inline-block;
height: 100px;
width: 100px;
background-color:#000;
margin: 5px;
}