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

标签 css html

我有两个 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/

相关文章:

javascript - 如何将 "Different"多个 <Button> 函数转换为带有 <Select> 的通用函数?

javascript - 如何检测 PDF 数据对象是否在 html 对象中加载/播放/有效

css - SVG 动画 : drawing a line from the center

javascript - 如何将光标位置设置为文本字段的初始位置?

css - 按 ID 设置 Angular2 组件样式

jquery - 第一个 child 在 CSS 菜单中移动

javascript - 选择前一个父jQuery的 child

css - 为什么我的段落元素大小不同?

html - 网站在手机上看起来不一样

javascript - 如何通过给定的URL获取YouTube音频数据