gpt4 book ai didi

html - Textarea(错误地?)从父类继承空白 css 属性

转载 作者:搜寻专家 更新时间:2023-10-31 21:49:45 24 4
gpt4 key购买 nike

我在父 div 中有一个文本区域。父 div 有 'white-space: nowrap'。 textarea 应该继承'white-space: nowrap'吗?在 IE11 中,textarea 继承了 'nowrap'。 Chrome 忽略继承的“nowrap”,而是使用用户代理样式表中的“white-space: pre-wrap”。我知道我可以通过显式指定文本区域的空白属性来解决这个问题。 我是否必须明确设置文本区域的空白,或者这是 IE11 错误?

以下 JSFiddle 演示了该问题。 (在 IE11 和 Chrome 中打开它并注意区别)。

http://jsfiddle.net/sTAB3/1/

这是 JSFiddle 中的代码:

.a {
white-space: nowrap;
}

<div class="a">
<textarea id="log" rows="20" cols="50">If I may... Um, I'll tell you the problem with the scientific power that you're using here, it didn't require any discipline to attain it. You read what others had done and you took the next step. You didn't earn the knowledge for yourselves, so you don't take any responsibility for it. You stood on the shoulders of geniuses to accomplish something as fast as you could, and before you even knew what you had, you patented it, and packaged it, and slapped it on a plastic lunchbox, and now you're selling it</textarea>
</div>

最佳答案

这似乎是一个 IE 11 错误,它允许父元素的 white-space 属性被子 textarea 继承。这应该被视为意外行为。

我会将 white-space: pre-wrap 应用于文本区域并将其视为 IE 11 错误修复。

我找不到官方错误报告(欢迎提供来源),但下面是此错误引起的问题的两个示例。

示例 1

Example source

来自链接:

Ticket description textarea doesn't wrap on whitespace in IE11

enter image description here

示例 2

Example source

Internet Explorer 11 word wrap is not working It seems that word wrapping no longer works for textarea elements in IE 11. In IE 10 and earlier, FF, Safari, and Chrome word wrapping works as expected.

关于html - Textarea(错误地?)从父类继承空白 css 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24706698/

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