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

Mathlive中mathfield输入框垂直滚动功能不生效问题咨询

问题原因

MathLive 初始化生成的内置 math-field 元素默认会添加 overflow-y: hidden 样式,你给外层 .input 容器设置的垂直滚动属性无法作用到 MathLive 渲染的内部内容区域,所以导致垂直滚动失效。

解决方法

方案1:CSS 强制覆盖内置样式

在你的样式文件中新增如下规则,强制修改 MathLive 内部元素的滚动属性:

.input math-field {
  overflow-y: auto !important;
  height: 100% !important;
  max-height: 100% !important;
}

方案2:初始化时传入自定义样式配置

修改 MathLive 初始化代码,通过 customStyle 字段直接配置内置元素的样式:

componentDidMount() {
  document.body.append(this.container);
  this.editor = window.MathLive.makeMathField(this.editorRef.current, {
    customStyle: `
      :host {
        overflow-y: auto;
        height: 100%;
      }
    `,
    onKeystroke: (e, keyCode) => {
      if (keyCode == "[Space]") {
        this.insertLatex("\\,");
      }
    }
  })
}

注意事项

你当前样式中设置的高度是 18rem,如果需要的是180px,直接替换对应高度值即可。另外确认外层没有父元素设置 overflow: hidden 拦截滚动行为。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.18 18:15:01