In the td or div attribute of this line of text, add
The code is as follows:
Style = "word-break: break-all ;"
Example
| The code is as follows: |
Copy code |
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <Html xmlns = "http://www.w3.org/1999/xhtml"> <Head> <Meta http-equiv = "Content-Type" content = "text/html; charset = utf-8"/> <Title> disable automatic line feed with CSS </title> <Style type = "text/css"> P {white-space: nowrap} </Style> </Head> <Body> <P> This is a text test that disables automatic line breaks. This is a text test that disables automatic line breaks, this is a text test that disables automatic line breaks, this is a text test that disables automatic line breaks. <p> </Body> </Html> |
The effect is as follows:
In the following example, the text can be wrapped only when spaces or line breaks are encountered, for example:
| The code is as follows: |
Copy code |
<Style type = "text/css"> Div {width: 300px; border: 1px solid red; margin: 10px; overflow: hidden ;} . Nowrap {white-space: nowrap ;} </Style> <Div class = "nowrap"> This is a long piece of text with no spaces or line breaks in it. It does not automatically wrap the text until it is truncated. </div> <Div> This is a long text with no spaces or line breaks in the middle, but it will automatically wrap </div> |
The text in the above two divs is too wide. The line feed in the first one is forbidden, and the text in the extra width is intercepted. The second one is not set, so the text is automatically wrapped.