简体   繁体   中英

Position absolute without parent height

I would like to place 4 divs like the following picture; the parent div has unknown height (auto). Each div would have an image with 100% fit, then the height of the divs are also unknown.

I was thinking using absolute position on the divs, but I need the background of the parent. Is there some jquery plugin or css3 trick to do the job?

在此处输入图片说明

JQuery:

$(document).ready(function() {
    var divHeight = $('.div1').height() + $('.div2').height();
    $('.containerDiv').css({ "height" : divHeight });
});

This will tally the heights of .div1 and .div2 (of course you can adjust to your liking) and apply that height to whatever your containing div, or whatever div you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM