I'm trying to split an image into a left and right side. I did this but I want the div to be centered and fill the browser so the images are edge to edge and be responsive. Right now it's all flush to the left.
I put a border so you can see that it's in fact two images put together to make one - 600x900 each.
JSFIDDLE: https://jsfiddle.net/omarel/vnc522vu/3/
HTML
<div id="centercontainer">
<div id="scrollablecontainer">
<img id="leftside" class="halfCompositionLeft" src="https://dl-web.dropbox.com/get/pool_left.jpg?_subject_uid=9047713&w=AAC25lQ4ebCI8ajjRKwfi_TANvxEYQruCRN5PQDEEZ70Uw">
<img id="rightside" class="halfCompositionRight" src="https://dl-web.dropbox.com/get/pool_right.jpg?_subject_uid=9047713&w=AABZnKZrODSr9rGU5kOX7q2EHycNMAqq-mvlUxn0T5tVAg">
</div>
</div>
CSS:
.scrollableSectionContainer section>img {
position:absolute;
}
.centercontainer {
margin: 0 auto;
overflow: hidden;
top: 0%;
right: 0%;
width: 100%;
height: 100%;
opacity: 0;
position: relative;
}
.scrollablecontainer {
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%
}
.halfCompositionLeft {
position:absolute;
top:0px;
left:0px;
width:600px;
height:900px;
}
.halfCompositionRight {
position: absolute;
top: 0px;
left: 600px;
width: 600px;
height: 900px;
border:#FFF solid thin;
}
Try this:
#halfCompositionLeft{
position: absolute; //Absolute Positioning.
top: 0px; //Top of the page.
left: 0px; //Leftmost side.
width: 50%; //Fill half the page.
height: 100%; //Fill page vertically.
}
#halfCompositionRight{
position: absolute; //Absolute Positioning.
top: 0px; //Top of the page.
left: 50%; //Start halfway through the page.
width:50%; //Fill rest of page.
height: 100%; //Fill page vertically.
}
That uses CSS percentages rather than pixel values, which dynamically sets size and position based on page size. To complete this, simply make the full box 100% wide and 100% high, and it will fill the page appropriately.
EDIT: CSS for placing div parallel underneath:
#halfCompositionLeft2{
position: absolute; //Absolute Positioning.
top: 100%; //Similar, but at the bottom of the page, under the top div.
left: 0px; //Leftmost side.
width: 50%; //Fill half the page.
height: 100%; //Fill page vertically.
}
#halfCompositionRight2{
position: absolute; //Absolute Positioning.
top: 100%; //Similar, but at the bottom of the page, under the top div.
left: 50%; //Start halfway through the page.
width:50%; //Fill rest of page.
height: 100%; //Fill page vertically.
}