Auto Div height depend on another one

后端 未结 3 1570
你的背包
你的背包 2021-01-15 12:09

I have the following scenario I want Div2 height to resize depend on the content of Div3 how I can do that ?

----------------------------------
.      DIV1          


        
3条回答
  •  一生所求
    2021-01-15 12:42

    You could use the display: table-cell css property, though be warned, it's CSS3 and doesn't have a lot of support in anything older than IE8.

    Example:

    CSS:

    .div1 {
        display: table;
    }
    .div1 > div {
        border: 1px solid #000;
        width: 200px;    
        display: table-cell;
    }
    .div3 {
        height: 500px;
    }
    

    Fiddle: http://jsfiddle.net/97NJR/

提交回复
热议问题