我在父div內有一個textarea。父div有'空白:nowrap'。 textarea是否應該繼承'white-space:nowrap'?在IE11中,textarea繼承了'nowrap'。 Chrome會忽略繼承的'nowrap',而是使用用戶代理樣式表中的'white-space:pre-wrap'。我知道我可以通過明確指定textarea的空白屬性來解決這個問題。 我是否必須明確地設置textarea的空白,還是這是IE11的錯誤?Textarea(錯誤地?)繼承父類的空白css屬性
以下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 9,它看起來像鉻一樣,以防萬一。我的猜測是微軟認爲它工作得很好,並將其固定在較新的版本中。 – JStephen
這在技術上不是IE11的錯誤,因爲這裏有[沒有規範強制行爲](http://www.w3.org/html/wg/drafts/html/master/rendering.html#rendering)。但是,[HTML 5.1規範10.5.16](http://www.w3.org/html/wg/drafts/html/master/rendering.html#the-textarea-element-0)表示textarea元素應該有'空格:pre-wrap;'應用(這將優先於默認繼承)*如果* IE11宣稱[支持默認渲染](http://www.w3.org/html/wg/drafts /html/master/infrastructure.html#renderingUA) – Alohci