有谁知道如何扩展这个 div 文本框,以便用户可以看到整个文本,或者有没有办法放置功能滚动。我尝试了最后一个,但它不起作用。我尝试了 fit-content 但它不起作用:

代码是:
谢谢您的帮助!
<textarea></textarea>搭配风格使用overflow: auto; max-height: 4em; height: max-content; min-height: 2em;
您可以添加一个小 JS 脚本:
const tx = document.getElementsByTagName("textarea");
for (let i = 0; i < tx.length; i++) {
tx[i].setAttribute("style", "height:" + (tx[i].scrollHeight) + "px;overflow-y:hidden;");
tx[i].addEventListener("input", onInput, false);
}
function onInput() {
this.style.height = "auto";
this.style.height = (this.scrollHeight) + "px";
}
textarea{
resize: none;
}
<textarea></textarea>
我假设你使用这个插件。它在进入“滚动条模式”的特定行数处调整位大小。遗憾的是,我没有找到禁用滚动模式的设置。