jquery - CSS 并排 DIV - Dynatree 不水平填充

标签 jquery css dynatree

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

enter image description here

enter image description here

这是 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。知道出了什么问题吗?感谢您的帮助!

最佳答案

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

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

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

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

关于jquery - CSS 并排 DIV - Dynatree 不水平填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8927485/

相关文章:

javascript - jquery on 不会对由clone()添加的元素使用react

javascript - Dynatree 选择第一个节点作为默认选定节点。

javascript - 向下滚动时无法将拖动的 div 拖放到图像的一部分

jquery - 带动画的动态高度和所有元素垂直居中对齐

css - dynatree 列布局 css 不起作用

javascript - 如何在空动态树上删除节点

javascript - 有没有办法使用 jQuery 将内容发布到服务器端 .txt 文件?

javascript - 为什么将 nan 添加到数据中?

javascript - 在 .load() 中的元素上使用 jQuery

html - 重叠输入表单,我在 CSS 中这样做是否正确?