简体   繁体   中英

Facebook wrapping text

Please how to move word to next line if it's alone in this line? (Facebook does this when adding ads)

I use

word-break: break-word;

But it gives some lines with one word!

The declaration word-break: break-word is nonstandard and browser-specific. It is poorly documented but probably intended to do the same as word-break: break-all as per CSS 3 Text . This means allowing line breaks at any point, even inside a word, just breaking anywhere (without inserting a hyphen). This may be acceptable in some contexts, but surely not for normal English text, for example.

As a completely unrelated question, to prevent a word from being displayed alone in a line, you need to bind it together with an adjacent word. The simplest way is to use a no-break space instead of a normal space, eg replacing <p>... foo bar.</p> by <p>... foo&nbsp; bar.</p> <p>... foo&nbsp; bar.</p> To do the same in CSS, you need extra markup: <p>... <span style="white-space: nowrap">foo bar.</span></p>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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