CSS forced word wrapping in English

Source: Internet
Author: User
Tags implement

Automatic line-wrapping problem, the normal character of the line is more reasonable, and continuous numbers and English characters will often be large containers, quite a headache, the following is a CSS how to implement the method of line-wrapping
For block-level elements such as div,p, the wrapping (Asian and non-Asian text) elements have the default White-space:normal, and the HTML is automatically wrapped when the width is defined
<div id= "Wrap" > Normal text Wrapping (Asian and non-Asian text) elements have the default white-space:normal, when defined </div>
Css
#wrap {white-space:normal; width:200px;}
1. (ie browser) consecutive English characters and Arabic numerals, using Word-wrap:break-word or Word-break:break-all;
#wrap {word-break:break-all; width:200px;}
Or
#wrap {word-wrap:break-word; width:200px;}
<div id= "Wrap" >abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111</div>
Effect: You can implement line wrapping
2. (Firefox browser) consecutive English characters and Arabic numerals break, all versions of Firefox did not solve this problem, we have to let go beyond the bounds of the characters hidden or, add a scroll bar to the container
Firefox3.6 test can use Word-wrap:break-word to force a newline, but Word-break:break-all is still invalid
#wrap {word-break:break-all; width:200px; overflow:auto;}
<div id= "Wrap" >abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111</div>
Effect: Container normal, content hidden
For table
1. (ie browser) use table-layout:fixed; Force table width, superfluous content hide
<table style= "table-layout:fixed" width= ">"
<tr>
<td>abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss
</td>
</tr>
</table>
Effects: Hide Unwanted content
2. (ie browser) use table-layout:fixed; Force table width, inner td,th use word-break:break-all; or word-wrap:break-word; line-Wrapping
<table width= "style=" table-layout:fixed; >
<tr>
&LT;TD width= "25%" style= "Word-break:break-all; ">abcdefghigklmnopqrstuvwxyz 1234567890
</td>
&LT;TD style= "Word-wrap:break-word;" &GT;ABCDEFGHIGKLMNOPQRSTUVWXYZ 1234567890
</td>
</tr>
</table>
Effect: You can change lines
3. (ie browser) in the td,th nested div,p, etc. using the above mentioned Div,p line-wrapping method

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.