2016-12-05 48 views
0

樣式詞的斷行斷與溢流

#test { 
    overflow-x: auto; 
    white-space: pre-wrap; /* css-3 */ 
    white-space: -moz-pre-wrap !important; 
    white-space: -pre-wrap; 
    white-space: -o-pre-wrap; 
    width: 99%; 
    word-wrap: break-word; 
} 
#wrap { 
    margin: 0 auto; width: 50%; 
} 

詞語的DIV ID = 「測試」 像遊:

no //this is end of first line 
thing //this is beginning of the next line 

<div id="wrap"> 
    <div id="test"></div> 
</div> 

原詞是nothing

如何解決那?

回答

0

只使用white-space: nowrap;可以讓整個單詞不中斷。不過,我相信了空白區不能nothing之間被刪除,除非你從文本中刪除,並把它寫成nothing

#test { 
 
    overflow-x: auto; 
 
    white-space: nowrap; 
 
    width: 99%; 
 
    word-wrap: normal; 
 
} 
 
#wrap { 
 
    margin: 0 auto; width: 50%; 
 
}
<div id="wrap"> 
 
    <div id="test"> 
 
    no 
 
thing 
 
    </div> 
 
</div>