html - 如何将图标放在 jsTree 树的顶部

标签 html css jstree

所以我有一个jsTree树,我希望我可以放一个像这样的“孤星”类型的图标...

在树的最顶端:

loneStar

jsTree 是 jquery 插件,提供交互式树。它完全免费、开源并在 MIT 许可证下分发。 jsTree 易于扩展、主题化和配置,它支持 HTML 和 JSON 数据源以及 AJAX 加载。

jsTree 在任一框模型(内容框或边框框)中都能正常运行,可以作为 AMD 模块加载,并且具有用于响应式设计的内置移动主题,可以轻松定制。它使用 jQuery 的事件系统,因此在树中绑定(bind)各种事件的回调既熟悉又容易。

最佳答案

只需在容器上方添加一个 div,如下所示:

<div>
  <img src="star.png">
</div>
<div id="container" role="main" style="height: 430px;">
  <div id="tree" class="jstree jstree-1 jstree-default jstree-default-small" role="tree" aria-multiselectable="true" tabindex="0" aria-activedescendant="/" aria-busy="false" style="height: 430px;">
    <ul class="jstree-container-ul jstree-children jstree-striped" role="group">
      <li role="treeitem" aria-selected="false" aria-level="1" aria-labelledby="/_anchor" aria-disabled="true" aria-expanded="true" id="/" class="jstree-node  jstree-open jstree-last"><i class="jstree-icon jstree-ocl" role="presentation"></i><a class="jstree-anchor  jstree-disabled" href="#" tabindex="-1" id="/_anchor"><i class="jstree-icon jstree-themeicon folder jstree-themeicon-custom" role="presentation"></i>root</a>
        <ul role="group"
        class="jstree-children">
          <li role="treeitem" aria-selected="false" aria-level="2" aria-labelledby="MENU1_anchor" aria-expanded="false" id="MENU1" class="jstree-node  jstree-closed"><i class="jstree-icon jstree-ocl" role="presentation"></i><a class="jstree-anchor" href="#" tabindex="-1" id="MENU1_anchor"><i class="jstree-icon jstree-themeicon folder jstree-themeicon-custom" role="presentation"></i>MENU1</a>
          </li>
          <li role="treeitem" aria-selected="false" aria-level="2" aria-labelledby="MENU2_anchor" aria-expanded="false" id="MENU2" class="jstree-node  jstree-closed jstree-last"><i class="jstree-icon jstree-ocl" role="presentation"></i><a class="jstree-anchor" href="#" tabindex="-1" id="MENU2_anchor"><i class="jstree-icon jstree-themeicon folder jstree-themeicon-custom" role="presentation"></i>MENU2</a>
          </li>
        </ul>
      </li>
    </ul>
  </div>
  <div id="data" style="height: 430px;">
    <div class="content code" style="display: none; height: 430px;">
      <textarea id="code" readonly="readonly"></textarea>
    </div>
    <div class="content folder" style="display: none; height: 430px;"></div>
    <div class="content image" style="display: none; position: relative; height: 430px;">
      <img src="" alt="" style="display:block; position:absolute; left:50%; top:50%; padding:0; max-height:90%; max-width:90%;">
    </div>
    <div class="content default" style="text-align: center; height: 430px; line-height: 430px;">Select a file from the tree.</div>
  </div>
</div>

我没有star.png,但是看起来像这样

enter image description here

关于html - 如何将图标放在 jsTree 树的顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39218062/

相关文章:

html - 在我的案例中如何垂直对齐元素

c# - jstree下载

javascript - jsTree无法通过ID找到节点

html - 如何在输入下移动按钮?

javascript - 可拖放溢出问题

html - 切换到小屏幕(例如移动设备)时垂直对齐 div

html - 扩展 sidenav 时 CSS Hamburger 不旋转

javascript - 更改按钮的类别组

css - 使用图标字体 (Font Awesome) 看起来有点模糊而且太粗

jquery - jstree 重命名类中的所有节点