gpt4 book ai didi

asp.net - 在 IE 的多行文本框中隐藏垂直滚动条

转载 作者:技术小花猫 更新时间:2023-10-29 12:48:16 24 4
gpt4 key购买 nike

我有一个多行文本框:

<asp:TextBox ID="txtBody" runat="server"  TextMode="MultiLine" Rows="10" Width="95%" />

在 ie 中,即使文本框中的文本不占用 10 行,也有一个垂直滚动条。
在 firefox 中它不会发生,只有当文本超过 10 行时才会出现滚动条。

可以做什么?

最佳答案

将 CSS 样式溢出设置为自动:

<asp:TextBox ID="txtBody" runat="server" TextMode="MultiLine"
Rows="10" Width="95%" style="overflow:auto;" />

浏览器之间的默认行为不同,这就是为什么在 overflow 时您会在 IE 和 FF 中看到不同的行为。未指定。

要覆盖页面上所有多行文本框的默认浏览器行为,您可以将其添加到样式定义中。然后你不需要在每个文本框上包含内联样式:

注意:多行文本框是使用 HTML 标签 <textarea> 呈现的, 所以我们将为 textarea 指定 css 样式元素类型。

textarea {
overflow: auto;
}
<textarea id="txtBody1" rows="5">Text in 
textbox
with
many
lines,
so that
scrollbar
will
appear.
</textarea>
<textarea id="txtBody2" rows="5">Smaller text, no scrollbar.</textarea>

关于asp.net - 在 IE 的多行文本框中隐藏垂直滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1409979/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com