Set a DIV height equal with of another DIV

后端 未结 7 2427
终归单人心
终归单人心 2020-12-08 11:06

I have two DIVs, .sidebar and .content and I want to set .sidebar to keep the same height with the .content.

I\'ve tried the f

7条回答
  •  心在旅途
    2020-12-08 11:34

    $(window).resize(function(){
       var height = $('.child').height();
       $('.parent').height(height);
    })
    
    $(window).resize(); //on page load
    .parent{
      background:#ccc;
      display:inline-block;
      width:100%;
      min-height:100px;
    }
    .child{
      background:red;
      width:50%;
      position:absolute;
    }
    
    
    hellow i am floating as absolute
    hellow i am floating as absolute
    hellow i am floating as absolute
    hellow i am floating as absolute
    hellow i am floating as absolute
    hellow i am floating as absolute
    hellow i am floating as absolute
    hellow i am floating as absolute
    hellow i am floating as absolute
    hellow i am floating as absolute

提交回复
热议问题