【问题标题】:How can I wrap long lines without spaces in contenteditable如何在 contenteditable 中换行没有空格的长行
【发布时间】:2015-02-10 21:14:00
【问题描述】:

嘿, 我已经尝试了所有方法,但没有任何效果。

我有这个小提琴:http://jsfiddle.net/kauqdk9j/

<div id="test" contenteditable="true"></div>

#test { width:400px; height:30px; font-size:13px; border:1px solid #333; word-wrap:break-word; word-break: break-all;white-space: nowrap}

我在 CSS 中尝试过: word-wrap:break-word; word-break: break-all;white-space: nowrap,什么也没有发生。 有人可以帮我解决这个问题吗?

【问题讨论】:

    标签: css contenteditable


    【解决方案1】:

    换行

    #test {
        width:400px;
        height:30px;
        font-size:13px;
        border:1px solid #333;
    
        word-wrap: break-word;
        overflow-wrap: break-word;
        white-space: normal;
    }
    

    无包装

    #test {
        width:400px;
        height:30px;
        font-size:13px;
        border:1px solid #333;
    
        word-wrap: normal;
        overflow-wrap: normal;
        white-space: nowrap;
    }
    

    【讨论】:

    • 为了换行,我最终使用了word-wrap: anywhere; overflow-wrap: anywhere; white-space: break-spaces;
    猜你喜欢
    • 2010-09-26
    • 2013-10-10
    • 1970-01-01
    • 2011-03-15
    • 2014-09-22
    • 2023-04-04
    • 1970-01-01
    • 1970-01-01
    • 2018-02-05
    相关资源
    最近更新 更多