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

CKEditor工具栏固定顶部失效求助:内容可滚动工具栏随页滚动

CKEditor 工具栏随页面滚动消失,如何在页面可滚动场景下固定工具栏并实现内容区域滚动?

我需要实现的效果是:让CKEditor的工具栏固定在顶部,同时编辑器的内容区域可以滚动。但目前工具栏会随着页面滚动移出屏幕,而且因为这个组件所在的页面本身是可滚动的,直接用position:fixed属性无法解决问题。

另外,页面中的「Question Stem」标签是用Vuetify Toolbar组件包裹的,这个标签已经能保持在顶部。

现有CKEditor工具栏CSS:

.ck.ck-toolbar {
  align-items: center;
  display: flex;
  flex-flow: row nowrap;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

我已添加的内容滚动CSS:

#ckEditorQuestionStem .ck.ck-toolbar > .ck-toolbar__items {
   position: relative !important;
   z-index: 10;
}
#ckEditorQuestionStem .ck.ck-editor__main {
  max-height: 400px;
  overflow-y: auto;
  position: relative !important;
}

相关HTML结构截图:

CKEditor相关HTML结构

我已经尝试过调整CKEditor配置,在toolbar选项下添加viewportTopOffset: 50,也试过一些针对工具栏固定的方案,但都没能解决问题,求可行的解决办法。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.17 03:05:39