简体   繁体   English

如何防止IE Con​​tent Editable div中的自动换行?

[英]How to prevent word-wrap in an IE Content Editable div?

The Problem 问题

I have a div that has contenteditable set to true . 我有一个将contenteditable设置为truediv In Chrome, when the edge of the div is reached while typing, it shifts the entire word to the next line as expected. 在Chrome浏览器中,键入时到达div的边缘时,会将整个单词移到预期的下一行。 I present Exhibit A: 我现在展示图A:

在此处输入图片说明

IE, as usual, doesn't behave as expected. IE像往常一样不会表现出预期的行为。 When the edge of the div is reached while typing it breaks the word. 当在键入时到达div的边缘时,它将中断单词。 I present Exhibit B: 我展示了附件B:

在此处输入图片说明

The HTML HTML

A simple div , with the contenteditable set to true: 一个简单的div ,将contenteditable设置为true:

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

The CSS CSS

The form-control is from Twitter's Bootstrap CSS. form-control来自Twitter的Bootstrap CSS。 The custom styles are: 自定义样式为:

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

Attempts to Fix 尝试修复

I've tried the following with CSS, with no luck: 我已经用CSS尝试了以下方法,但是没有运气:

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

I've tried the route suggested in this question , but it didn't work. 我已经尝试过此问题中建议的路线,但是没有用。 Any other suggestions? 还有其他建议吗?

Update 更新

I created a fiddle to demo the problem, but I can't recreate it there. 我创建了一个小提琴来演示该问题,但是无法在此处重新创建它。 I've included the Bootstrap CSS to get it as close to the actual environment as possible. 我包括了Bootstrap CSS,以使其尽可能接近实际环境。

The div is added in the Bootstrap Modal with JS. div被添加到带有JS的Bootstrap Modal中。 I'm not sure how that could change things, but hopefully that provides more background information. 我不确定这将如何改变事情,但希望可以提供更多背景信息。

Which IE versions have you tried so far? 到目前为止,您尝试过哪些IE版本?

I've tried it in IE 9-11 and no such problem persists. 我已经在IE 9-11中尝试过了,没有这样的问题仍然存在。

Try setting 尝试设定

word-wrap:break-word;

in your css style. 在你的CSS风格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM