我在父 div 中有一个文本区域。父 div 有 'white-space: nowrap'。 textarea 应该继承'white-space: nowrap'吗?在 IE11 中,textarea 继承了 'nowrap'。 Chrome 忽略继承的“nowrap”,而是使用用户代理样式表中的“white-space: pre-wrap”。我知道我可以通过显式指定文本区域的空白属性来解决这个问题。 我是否必须明确设置文本区域的空白,或者这是 IE11 错误?
以下 JSFiddle 演示了该问题。 (在 IE11 和 Chrome 中打开它并注意区别)。
这是 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
来自链接:
Ticket description textarea doesn't wrap on whitespace in IE11
示例 2
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/