1

我在 JSP 中有两个并排的 DIV。它运行良好,但有一个例外:我无法让 jQuery Dynatree 正确填充左侧 DIV 的水平空间:

在此处输入图像描述

在此处输入图像描述

这是HTML:

<div id="sub-title">
   <div id="sub-left">
    <fieldset class="search-fields">
        <legend>Files Found</legend>
        <!-- Add a <div> element where the tree should appear: -->
        <div id="tree"> 
        </div>
      </fieldset>
   </div>
   <div id="sub-right">
     <fieldset class="search-fields">
        <legend id="selectedFileLegend">Selected File Contents</legend>
        <textarea name="fileContents" id="fileContents" rows="20" readonly="readonly" wrap='off'>
(select via tree on left)
        </textarea>
     </fieldset>
   </div>
   <div class="clear-both"></div>
</div>

和 CSS:

#sub-left {
/*    background: #99FF99;  pale green */
/*    border:1px dashed; */
   float: left;
   width: 24%;
}
#sub-right {
/*    background: #FFCC99;  pale orange */
/*    border:1px dashed; */
   float: right;
   width: 73%;
}
#sub-title { 
    overflow:hidden; 
}
.clear-both {
   clear: both;
}

#tree {
  vertical-align: top;
  width: 250px;
}

我当然也使用 dynatree CSS。知道有什么问题吗?谢谢您的帮助!

4

1 回答 1

2

您的#tree宽度设置为 250px;

#tree {
  vertical-align: top;
  width: 250px;
}

如果将其设置为100%(或完全删除 width 属性),它将填充其容器 ( #sub-left)。

这也是#sub-left当您缩小窗口(第二张图像)时它会延伸出容器的原因,因为 250px 变得大于可用大小的 24%。

于 2012-01-19T14:17:06.150 回答