How to force child div to be 100% of parent div's height without specifying parent's height?

前端 未结 26 1655
刺人心
刺人心 2020-11-22 06:52

I have a site with the following structure:

<
26条回答
  •  无人及你
    2020-11-22 07:24

    using jQuery:

    $(function() {
        function unifyHeights() {
            var maxHeight = 0;
            $('#container').children('#navigation, #content').each(function() {
                var height = $(this).outerHeight();
                // alert(height);
                if ( height > maxHeight ) {
                    maxHeight = height;
                }
            });
            $('#navigation, #content').css('height', maxHeight);
        }
        unifyHeights();
    });
    

提交回复
热议问题