Make div expand to occupy available height of parent container

前端 未结 9 473
别那么骄傲
别那么骄傲 2021-01-11 10:28

I have this code:

html:

short

Lorem ipsum dolor sit amet, consec
9条回答
  •  南笙
    南笙 (楼主)
    2021-01-11 10:57

    How about a fixed height:

    .tile h3 {
        height: 65px;
        display: inline-block;
        overflow: hidden;
    }
    

    Or accompanied by js (jQuery):

    // Height handler
    var headHeight = 0;
    
    // Iterate throug all H3s an get highest
    jQuery( 'h3' ).each( function() {
    
        // Get current height
        var currentHeight = jQuery( this ).height();
    
        // If higher as handler set as handler
        if( currentHeight > headHeight ) {
            headHeight = currentHeight;   
        }
    
    } );
    
    // Set the height of all H3s
    jQuery( 'h3' ).css( 'height', headHeight );
    

    This would be a pretty robust solution ...

提交回复
热议问题