Here is one way of building this layout using CSS table cells.
Start with this HTML:
<div class="wrapper">
<div class="left"></div>
<div class="center">
<img src="http://placekitten.com/400/200">
</div>
<div class="right"></div>
</div>
and apply the following CSS:
.wrapper {
display: table;
width: 100%;
border: 1px solid blue;
}
.left, .center, .right {
display: table-cell;
border: 1px dotted blue;
vertical-align: top;
}
.center {
width: 1%;
}
.left, .right {
width: 50%;
}
.left {
background-image: url(http://placekitten.com/4/100);
background-repeat: repeat-x;
background-position: left center;
}
.right {
background-image: url(http://placekitten.com/10/100);
background-repeat: repeat-x;
background-position: left center;
}
.center img {
display: block;
}
The .wrapper
has a width of 100%, so it fills the width of the page.
The child elements .left
, .center
and .right
are table cells.
.center
is forced to shrink-to-fit the image by setting the width to some small value, for example, 1%.
The .left
and .right
elements are set to the same width, 50%, which forces them to take up the remaining space equally.
You can apply background images as needed to any of the child elements.
See demo at: http://jsfiddle.net/audetwebdesign/pG2v3/
Note: Most modern browsers support CSS table cells.
It's why I didn't attempt to add some example that is not ok!
– Ephy L Jun 17 '14 at 12:16