JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<div class="row-fluid" id="theContainer">
<div class="col-sm-6 resizeMe">
<img class="filler" src="http://www.keenthemes.com/preview/metronic/theme/assets/global/plugins/jcrop/demos/demo_files/image1.jpg" />
<img class="filler" src="http://www.keenthemes.com/preview/metronic/theme/assets/global/plugins/jcrop/demos/demo_files/image2.jpg" />
</div>
<div class="col-sm-6">
<img class="main-img" src="http://joombig.com/demo-extensions1/images/gallery_slider/Swan_large.jpg" />
</div>
</div>
<div class="row-fluid">
<div class="col-xs-12">
<h2 class="theWidth"></h2>
<div id="theBody">
<span class="sm6"></span>
<span class="imgH"></span>
</div>
<div id="DOMready">
<span class="sm6"></span>
<span class="imgH"></span>
</div>
<div id="onLoad">
<span class="sm6"></span>
<span class="imgH"></span>
</div>
</div>
</div>
CSS
.main-img {
width: 100%;
height: auto
}
#theContainer {
margin-top: 15px;
}
body {overflow:scroll;}
JavaScript
document.initPictures = function() {
$('.resizeMe').css({
'height': $('#theContainer .col-sm-6').eq(1).height(),
'display': 'flex',
'flex-direction': 'column',
'transition': 'height .4s cubic-bezier(0.55, 0, 0.55, 0.2)'
});
$('.resizeMe img').each(function() {
var src = $(this).attr('src');
$('.resizeMe').append('<div style="flex-basis: 50%; background-image: url(' + src + '); background-size:cover; background-position: center center"' + '</div>');
$(this).remove();
})
};
document.resizePictures = function() {
if ($('#theContainer').outerWidth() > 768) {
$('.resizeMe').css({
'height': $('#theContainer .col-sm-6').eq(1).height()
});
} else {
$('.resizeMe').css({
'height': $('.resizeMe').outerWidth()
});
}
$('.theWidth').text($('body').outerWidth());
};
$('.theWidth').text($('body').outerWidth());
var sm6height = $('#theContainer .col-sm-6').eq(1).height();
var imgHeight = $('#theContainer .col-sm-6').eq(1).find('img').height();
console.log("When called in <body>:");
console.log("#theContainer .col-sm-6 height: " + sm6height);
$('#theBody .sm6').text(sm6height);
console.log("Image height: " + imgHeight);
$('#theBody .imgH').text(imgHeight);
$(document).ready(function(){
var sm6height = $('#theContainer .col-sm-6').eq(1).height();
var imgHeight = $('#theContainer .col-sm-6').eq(1).find('img').height();
console.log("When called in DOM Ready:");
console.log("#theContainer .col-sm-6 height: " + sm6height);
$('#DOMready .sm6').text(sm6height);
console.log("Image height: " + imgHeight);
$('#DOMready .imgH').text(imgHeight);
});
window.onload = function(){
var sm6height = $('#theContainer .col-sm-6').eq(1).height();
var imgHeight = $('#theContainer .col-sm-6').eq(1).find('img').height();
console.log("When called in onLoad:");
console.log("#theContainer .col-sm-6 height: " + sm6height);
$('#onLoad .sm6').text(sm6height);
console.log("Image height: " + imgHeight);
$('#onLoad...