我的div会不断改变高度.如何获得第二个div以不断采用第一个div的高度? [英] I have a div that constantly changes height. How can I get a second div to constantly adopt the height that the first div is?

查看:74
本文介绍了我的div会不断改变高度.如何获得第二个div以不断采用第一个div的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含项目列表的div.用户能够在列表中添加/删除项目,因此div会不断更改高度以补偿列表大小的变化.

I have a div that contains a list of items. The user is able to add to/remove items from the list, so the div constantly changes height to compensate for the changing size of the list.

我在其右侧还有一个div,该div应该提供有关左侧项目的详细信息.如何在右边的div上保持与左边的div垂直垂直对齐并更改高度,以使其等于当前从左边的div列表中添加和删除项目时左边的div的高度?

I have another div to its right that is supposed to give details about the items on the left. How can I get the div on the right to constantly keep vertically aligned with the left div and change height so that it equals the height that the left div currently is, as items are added and removed from the left div's list?

推荐答案

display:table-cell将在这里为您提供帮助:

display:table-cell will help you here:

div { display:table-cell; border:1px solid; }

<div id=master>
  one<br>two
</div>
<div>
    three
</div>

这篇关于我的div会不断改变高度.如何获得第二个div以不断采用第一个div的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆