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

标签 html css whitespace

我在父 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/

相关文章:

Bash 脚本将目录中的所有 flv 文件转换为 mp3

javascript - 无法获取元素动画以等待 jquery 中的另一个元素动画

c - 在类 C 语言中,空格是否被视为标记?

javascript - 图片库中的图片定位

javascript - 在 html 表单中进行年龄验证时遇到问题

javascript - 淡出与 yOffset 位置相关的 div

javascript - 如果内容超过使用 JavaScript 的 html 表格的固定宽度,则将文本拆分到下一行

css - slider 周围显示空白 - 我尝试了两个不同的 slider 并且发生了同样的事情?

jquery - 垂直居中对齐全屏 div

javascript - 自动将文本拆分到多个框中