I'm trying to make all of the sub-elements in a div space nicely. I have set up the css using inline-block elements and floated elements. The child elements are a fixed size.
HTML
<div class="content">
<h2>Inline-block</h2>
<a href="#" class="i-b-item">I-B Item 1</a>
<a href="#" class="i-b-item">I-B Item 2</a>
<a href="#" class="i-b-item">I-B Item 3</a>
<a href="#" class="i-b-item">I-B Item 4</a>
<a href="#" class="i-b-item">I-B Item 5</a>
<a href="#" class="i-b-item">I-B Item 6</a>
<a href="#" class="i-b-item">I-B Item 7</a>
<a href="#" class="i-b-item">I-B Item 8</a>
<h2>Floated</h2>
<a href="#" class="f-item">Float Item 1</a>
<a href="#" class="f-item">Float Item 2</a>
<a href="#" class="f-item">Float Item 3</a>
<a href="#" class="f-item">Float Item 4</a>
<a href="#" class="f-item">Float Item 5</a>
<a href="#" class="f-item">Float Item 6</a>
<a href="#" class="f-item">Float Item 7</a>
<a href="#" class="f-item">Float Item 8</a>
<div style="clear:both"></div>
</div>
CSS
.content {
background: grey;
}
.content a{
padding: .5em;
margin: .5em;
height: 75px;
width: 150px;
background: white;
}
.i-b-item{
display: inline-block;
}
.f-item{
float: left;
display: block;
}
Basically when the window size changes, I want the child element margins to make them fill the remaining space. So instead of having the leftover space on the right, I'd like the margins of the child elements to expand to space all of the child elements evenly while still being left aligned.
I'd prefer not to do any calculations with Javascript, I'm hoping for a pure css solution but can't seem to get anything to work right.