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

折叠侧边栏时如何居中汉堡图标?已尝试justify-content: center无效

侧边栏折叠时汉堡图标居中解决方案

问题核心:侧边栏折叠后,.nk-sb-company仅设置了opacity:0,但仍占据页面宽度,导致头部flex容器无法让汉堡图标水平居中。

修改步骤

直接修改CSS,添加以下样式:

/* 折叠状态下让头部容器内容居中 */
.nk-sidebar.close .nk-sb-hrd {
  justify-content: center;
}

/* 彻底移除公司名称的占位,同时保留过渡动画 */
.nk-sidebar.close .nk-sb-company {
  opacity: 0;
  pointer-events: none;
  width: 0;
  overflow: hidden;
  transition: width 0.3s ease;
}

替换原有的.nk-sidebar.close .nk-sb-company样式即可。修改后,侧边栏折叠时公司名称会平滑收缩至无宽度,头部容器自动将汉堡图标水平居中,解决你遇到的问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.20 19:57:25