[UPDATE]
Looking for a solution that doesn't involve javascript or media queries as the user should be able to change the container size.
[/UPDATE]
In need of creating a grid layout for items.
- The container's width is flexible.
- The grid must always be centered.
- Items within the grid should be aligned to the left.
Seems like a simple task, but I'm struggling to find a solution!
Here's an example image illustrating what I'm aiming for:
Also, you can check out a jsfiddle here: 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;
}