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/

相关文章:

javascript - 更改图像的部分 URL 字符串

html - 当图像不适合时,剪切图像的底部而不是顶部

html - 将 MouseOn 与 CSS 链接悬停相结合

html - 如何设置标题内链接的底部位置

c - ncurses - mvwprintw 生成空格

javascript - Web 表单提交将我的浏览器引导至错误页面

css - 如何在悬停时向 ngFor 生成的元素添加类?

html - 表格拉伸(stretch) div

c++ - 与 fileIO 中的空格混淆

perl - 使用反引号时转义空格