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

自定义textarea滚动条hover时光标显示异常问题求助

问题

开发包含textarea元素的项目时,使用::-webkit-scrollbar自定义滚动条后出现异常:鼠标悬停在textarea的滚动条上时,光标显示为文本光标而非默认鼠标光标,但页面侧边的主滚动条不受此影响。

自定义滚动条代码
::-webkit-scrollbar {
  width: 20px;
}
}
::-webkit-scrollbar-track {
  background-color: transparent;
}
::-webkit-scrollbar-thumb {
  background-color: var(--color-7);
  border-radius: 20px;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  background-clip: content-box;
}
#editor::-webkit-scrollbar-thumb {
  border: 4px solid transparent;
}
::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-8);
}
解决方法

给textarea的滚动条轨道和滑块显式设置光标样式,覆盖textarea的文本光标继承行为:

#editor::-webkit-scrollbar-track,
#editor::-webkit-scrollbar-thumb {
  cursor: default;
}

如果希望所有自定义滚动条都统一使用默认鼠标光标,也可以全局设置:

::-webkit-scrollbar-track,
::-webkit-scrollbar-thumb {
  cursor: default;
}

内容的提问来源于stack exchange,提问作者Henriks Matiass Nilsens

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.11 22:41:17