diff --git a/bricks/css/bricks.css b/bricks/css/bricks.css index 70e2c61..8b151a3 100755 --- a/bricks/css/bricks.css +++ b/bricks/css/bricks.css @@ -612,6 +612,12 @@ hr { } .auto-textarea { + /* 1. 确保计算模型一致 */ + box-sizing: border-box; + /* 2. 允许元素内部处理滚动事件,不传递给父层 */ + touch-action: pan-y; + /* 3. 极其重要:有些 H5 框架会禁用默认滚动,这里强制开启 */ + pointer-events: auto !important; width: 100%; min-height: 40px; /* 初始高度 */ max-height: 150px; /* 最大高度:超过此高度将滚动 */ diff --git a/bricks/input.js b/bricks/input.js index 688cfee..2f0c886 100644 --- a/bricks/input.js +++ b/bricks/input.js @@ -922,9 +922,9 @@ bricks.UiText =class extends bricks.UiType { opts.dynsize = opts.dynsize || true; opts.cfontsize = opts.cfontsize || 1; if (opts.css){ - opts.css += 'auto-textarea'; + opts.css += ' inputbox auto-textarea'; } else { - opts.css = 'auto-textarea'; + opts.css = 'inputbox auto-textarea'; } super(opts); this.uitype='text'; @@ -942,6 +942,8 @@ bricks.UiText =class extends bricks.UiType { const scrollHeight = el.scrollHeight; // 3. 获取 CSS 中定义的 max-height (150px) const maxHeight = parseInt(window.getComputedStyle(el).maxHeight); + const paddingTop = parseInt(style.paddingTop); + const paddingBottom = parseInt(style.paddingBottom); if (scrollHeight >= maxHeight) { // 4. 如果内容高度超过最大高度,固定为最大高度并显示滚动条