我刚刚创建了一个 div。当我键入内容时,我会提供一个 White-space: Normal
函数来自动换行。此功能适用于 Chrome、Opera 和 Safari 浏览器。但是在 Mozilla Firefox 和 Edge 浏览器中没有换行。我还尝试了 Word-wrap: break-word
功能。这也不起作用。请给我一个解决方案。
<div class = "list-name-field" id = "SAVE_LIST" style = "white-space: normal; width: 240px; min-height: 35px; border-radius: 3px; margin-left: auto; margin-right: auto; background-color: #ccc; margin-top: 5px; " contenteditable = "true" data-placeholder = "Add a List..."></div>
最佳答案
如果需要打断一个长单词,需要加上word-break: break-all
<div class = "list-name-field" id = "SAVE_LIST" style = "white-space: normal;word-break: break-all; width: 240px; min-height: 35px; border-radius: 3px; margin-left: auto; margin-right: auto; background-color: #ccc; margin-top: 5px; " contenteditable = "true" data-placeholder = "Add a List..."></div>
关于javascript - 自动换行不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38827202/