Fill remaining vertical space - only CSS

前端 未结 9 1376
日久生厌
日久生厌 2020-11-28 09:15

I need to fill the remaining vertical space of #wrapper under #first with #second div.

I need an only CSS sol

9条回答
  •  有刺的猬
    2020-11-28 09:38

    you need javascript and some client side calculations: http://jsfiddle.net/omegaiori/NERE8/2/

    you will need jquery to effectively achieve what you want. this function is very simple but very effective:

    (function () {
    
    
        var heights = $("#wrapper").outerHeight(true);
        var outerHeights = $("#first").outerHeight(true);
        jQuery('#second').css('height', (heights - outerHeights) + "px");
    
    })();
    

    first it detects the wrapper height, as it is set to 100% it's different everytime (it depends on what screen you are landing). in the second step it gives the #second div the appropriate height subtracting from the wrapper height the #first div height. the result is the available height left in the wrapper div

提交回复
热议问题