You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求适配jstree的大深色箭头节点展开/收起CSS样式

Custom CSS for Large Dark Arrow Expand/Collapse Icons in jstree 3.3.5

Hey there! As someone who’s tinkered with jstree before, I totally get wanting to swap those default tiny icons for more prominent dark arrows. Since you’re using version 3.3.5, here’s a custom CSS solution tailored to your needs that’ll replace the default 32px icons with the bold arrow style you’re aiming for:

Custom CSS Snippet

/* Hide the default jstree expand/collapse icons */
.jstree-icon.jstree-ocl {
    background-image: none !important;
    width: 24px; /* Adjust size to match your desired arrow scale */
    height: 24px;
    position: relative;
}

/* Style for collapsed nodes (right-pointing arrow) */
.jstree-node.jstree-closed > .jstree-icon.jstree-ocl::after {
    content: "▶";
    color: #222; /* Dark shade—tweak this to match your reference */
    font-size: 20px; /* Adjust arrow size here */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Style for expanded nodes (down-pointing arrow) */
.jstree-node.jstree-open > .jstree-icon.jstree-ocl::after {
    content: "▼";
    color: #222;
    font-size: 20px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Optional: Adjust child node spacing to match new icon size */
.jstree-children {
    padding-left: 30px; /* Match this to your icon width + extra spacing */
}

How to Implement This

  • Load order matters: Make sure this custom CSS is added after the default jstree style.min.css file. This ensures your styles override the default theme’s settings.
  • Tweak to match your reference: Adjust values like font-size, color, and width to get the exact size and darkness you want from your screenshot. If you want an even bigger arrow, bump the font-size to 24px or higher.
  • Alternative for custom shapes: If you don’t want to use Unicode arrows, you can replace the content values with background SVG images—just swap the content line for background: url('your-arrow-svg-path') center/contain no-repeat; and adjust the sizing accordingly.

Quick Tips for New jstree Users

  • The !important flag ensures we fully overwrite the default background image from jstree’s theme.
  • If your jstree is nested inside a custom container, you might need to add that container’s class to the CSS selectors to boost specificity (e.g., .my-custom-container .jstree-icon.jstree-ocl).

内容的提问来源于stack exchange,提问作者Yusuf

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 04:04:42