gpt4 book ai didi

css - div 高度取决于另一个 div 高度

转载 作者:太空宇宙 更新时间:2023-11-03 21:34:55 25 4
gpt4 key购买 nike

我有两个 div,其中一个依赖于另一个。

|Second Div| |First Div|
| | | |
| | | |
| | | |

定义第一个div的高度:

height:auto;

我的问题是如何定义第二个 div 高度,使其与第一个一样。

最佳答案

<div class="div1">first div</div>   
<div class="div2"></div>

CSS:

 div{display: table-cell;width: 100px;vertical-align: top}  /*display: table-cell;*/
.div1{height:auto; background:red;}
.div2{background:green;}

工作 jsFiddle http://jsfiddle.net/L54xz1h9/4/

关于css - div 高度取决于另一个 div 高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27201935/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com