0

我有一个字段集(左)div(右)对。fieldset 的内容是固定的,但它具有 hide()/show() 元素,例如 [Next] 按钮。当这些控件切换时,它会改变 fieldset 控件的高度。我想用右侧的 div 跟随这个高度。如何?这不是调整大小事件...

-<fieldset>-----------------------<div>-----
|                                |         |
|                                |         |
|                                |         |
|                                |         |
|                                |         |
|                                |---------|
|             [Next]             |         
----------------------------------

HTML

<div class="attach">
    <p>something</p>
</div>
<fieldset class="left">
    <p>lotsa content</p>
    <p class="message">
        <button id="n" type="button">Next &gt;</button>
        <span></span>
    </p>
</fieldset>

CSS

body {
    width: 720px;
}
fieldset.left {
    border-width: 1px 1px 1px 1px;
}
div.attach {
    position: relative;
    float: right;
    border: thin solid LightGray;
    right: 1px;
    width: 120px;
    height: 242px;
}
4

2 回答 2

0

如何将它们都放在另一个 div 中并给现有的一个:

div.attach {
    height: 100%
}
于 2013-02-21T12:44:50.207 回答
0

如果您知道正确区域的内容不会溢出容器,您可以使用绝对定位,就像这个小提琴http://jsfiddle.net/vasmB/2/

这是重要的一点:

left: 100%; top: 0; bottom: 0; 

通过将 left 设置为 100%,您将始终拥有原始容器右侧的框,无论其宽度如何。顶部/底部设置为 0 将保持高度灵活。

于 2013-02-21T13:11:48.633 回答