You can try a clean css solution using positioning. I assume that you have a fixed size image in the center of the page. For example, let's say your image is 800 pixels wide, then
- Place left div with left 0px, right 50% and add right edge 400px
- Place the right div with left 50%, right 0px and add left edge 400px
Example: http://jsfiddle.net/F4kay/
(note that I adopted a smaller 256 pixel image width for a smaller jsfiddle window)
CSS
#left { position:absolute; left:0px; right:50%; top:0px; bottom:0px; margin-right: 128px; background-color:#ccc; } #right { position:absolute; left:50%; right:0px; top:0px; bottom:0px; margin-left: 128px; background-color:#ccc; }
HTML:
<div id="left">Left</div> <div id="right">Right</div>
As for the height of these divs, it's up to you how you handle it: top / bottom: 0px or fixed / percentage height. In the example, I used top 0px and bottom 0px.
The trick is to basically add 2 divs, one of which occupies the left half of the screen, and the other the right. You add a marker to the inner edges of the div to open the inner content. I assumed a fixed width, but you can also use half the percentage width. If your image is dynamically resized using js, this is just a case of updating the fields.
For completeness, I have included a complete example using this technique. I think this is a clean solution.
Example: http://jsfiddle.net/Hqpyx/
CSS
body, .bgImage { background-image: url('http://flickholdr.com/640/1280/5'); } .flip { -moz-transform: scaleX(-1); -o-transform: scaleX(-1); -webkit-transform: scaleX(-1); transform: scaleX(-1); filter: FlipH; -ms-filter: "FlipH"; } body { background-position: top center; } #left { position:absolute; left:0px; right:50%; top:0px; bottom:0px; margin-right: 320px; background-position:top left; } #right { position:absolute; left:49.99%; right:0px; top:0px; bottom:0px; margin-left: 320px; background-position:top right; }
HTML:
<div id="left" class="bgImage flip"></div> <div id="right" class="bgImage flip"></div>
Personally, I would avoid flipping the image like this. If you have some kind of limitation, you can simply edit the background image and combine the half and half inverted versions, as
[ ] = full image { } = flipped image create an image that looks like }[ ]{