Use CSS to force line feed of tables or cells to prevent tables from being enlarged by English words or Chinese characters.

Source: Internet
Author: User
Tags arabic numbers

For Div, P, and other block-level elements
The normal text line feed (Asian text and non-Asian text) element has the default white-space: Normal, automatically wrap after the defined width
Html
<Div id = "Wrap"> normal Text wrap (Asian text and non-Asian text) elements have the default white-space: normal, when defined </div>
CSS
# Wrap {white-space: normal; width: 200px ;}
1. (IE browser) for continuous English characters and Arabic numbers, use Word-wrap: Break-word; or word-break: Break-all; to implement forced Line Disconnection
# Wrap {word-break: Break-all; width: 200px ;}
Or
# Wrap {word-wrap: Break-word; width: 200px ;}
<Div id = "Wrap"> abcdefghijklmnabcdefghijklmnabcdefghijklmn1111111 </div>
Effect: line breaks can be implemented.
2. (Firefox) continuous disconnection of English characters and Arabic numbers. All Firefox versions do not solve this problem. We only need to hide the characters that exceed the boundary or add a scroll bar to the container.
# Wrap {word-break: Break-all; width: 200px; overflow: auto ;}
<Div id = "Wrap"> abcdefghijklmnabcdefghijklmnabcdefghijklmn1111111 </div>
Effect: the container is normal and the content is hidden.
For Table
1. (IE browser) Use table-layout: fixed; to force the width of the table and hide unnecessary content.
<Table Style = "table-layout: fixed" width = "200">
<Tr>
<TD> abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss
</TD>
</Tr>
</Table>
Effect: Hide unnecessary content
2. (IE browser) Use table-layout: fixed; to force the width of the table, use Word-break: Break-all in the TD and th layers, or use Word-wrap: Break-word to wrap the line.
<Table width = "200" style = "table-layout: fixed;">
<Tr>
<TD width = "25%" style = "word-break: Break-all;"> abcdefghigklmnopqrstuvwxyz 1234567890
</TD>
<TD style = "word-wrap: Break-word;"> abcdefghigklmnopqrstuvwxyz 1234567890
</TD>
</Tr>
</Table>
Effect: line breaks are supported.
3. (IE browser) Embedding Div and P in TD and th adopts the wrap method of Div and P mentioned above.
4. (Firefox) Use table-layout: fixed; to force the width of the table, use Word-break: Break-all, or word-wrap: Break-word to form a new line, use overflow: hidden; hide the content that exceeds the limit. Here overflow: auto; cannot work.
<Table Style = "table-layout: fixed" width = "200">
<Tr>
<TD width = "25%" style = "word-break: Break-all; overflow: hidden;"> abcdefghigklmnopqrstuvwxyz1234567890 </TD>
<TD width = "75%" style = "word-wrap: Break-word; overflow: hidden;"> abcdefghigklmnopqrstuvwxyz1234567890 </TD>
</Tr>
</Table>
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.