I'm building a shopify theme. I have an instance where one div overlaps another. In the instance that the left div is shorter than the right div (positioned absolutely), the right div overlaps the div below it as expected.
To get round this issue I've tried writing some js which works in this jsFiddle but in my actual site the divs height is outputting as 0 so the function isn't working. For the life of me I can't figure out why the height for both left and right divs would be 0 and wondered if someone might be able to shed some light?
JS
var productImgHeight = $('.left').outerHeight(),
productInfoHeight = $('.right').outerHeight(),
gap = productInfoHeight - productImgHeight;
if (productImgHeight < productInfoHeight) {
alert(productImgHeight);
$('.left').css({"margin-bottom":gap+"px"});
} else {
$('.left').css({"margin-bottom":"0"});
}
Thanks in advance!