如何防止IE内容可编辑div中的自动换行?

时间:2014-03-21 16:43:16

标签: html css internet-explorer contenteditable

问题

我的div contenteditable设置为true。在Chrome中,当键入时到达div的边缘时,它会按预期将整个单词移动到下一行。我出示了附录A:

enter image description here

像往常一样,IE并不像预期的那样表现。当键入时到达div的边缘时,会中断该单词。我出示了附录B:

enter image description here

HTML

简单divcontenteditable设置为true:

<div id='bioEntryContainer' contenteditable='true' class='form-control'></div>

CSS

form-control来自Twitter的Bootstrap CSS。自定义样式是:

#bioEntryContainer { min-height:74px; overflow:auto; }

尝试修复

我已经尝试了以下CSS,没有运气:

overflow:hidden;
overflow-x:hidden;
white-space:nowrap;
white-space:pre;
display:inline-block; 

我已经尝试了this question中建议的路线,但它没有奏效。还有其他建议吗?

更新

我创建了一个fiddle来演示问题,但我无法在那里重新创建它。我已经包含了Bootstrap CSS,以使其尽可能接近实际环境。

使用JS在Bootstrap Modal中添加div。我不确定这会如何改变,但希望能提供更多背景信息。

1 个答案:

答案 0 :(得分:3)

到目前为止,您尝试过哪些IE版本?

我已经在IE 9-11中尝试过,并且没有这样的问题持续存在。

尝试设置

word-wrap:break-word;

以你的css风格。