Div to implement long English letter word wrap

Source: Internet
Author: User
Keywords Web page production CSS Tutorials
Tags automatic browser code content continuous firefox firefox browser force

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

Best CSS definition line break code

. wrap {table-layout:fixed; word-break:break-all; overflow:hidden;}
Here Overflow:hidden or auto;
=================================================================

For block-level elements such as Div,p
Wrapping of normal text (Asian and non-Asian text) elements have a default white-space:normal, which is automatically wrapped when the width is defined
html
<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


#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 break

<table width= "style=" table-layout:fixed; >
<tr>
<TD width= "mainly" style= "word-break:break-all; ">abcdefghigklmnopqrstuvwxyz 1234567890
</td>
<TD style= "Word-wrap:break-word;" >ABCDEFGHIGKLMNOPQRSTUVWXYZ 1234567890
</td>
</tr>
</table>

Effect: Can wrap

3. (ie browser) in the td,th nested div,p, etc. using the above mentioned Div,p line-wrapping method

4. (Firefox browser) use table-layout:fixed; Force table width, inner td,th use word-break:break-all; or Word-wrap:break-word; Use Overflow:hidden; hide beyond content, here Overflow:auto;


<table style= "table-layout:fixed" width= ">"
<tr>
<TD width= "mainly" style= "word-break:break-all; Overflow:hidden; ">abcdefghigklmnopqrstuvwxyz1234567890</td>
<TD width= "75%" style= "Word-wrap:break-word; Overflow:hidden; ">abcdefghigklmnopqrstuvwxyz1234567890</td>
</tr>
</table>

Effects: Hide more than content

5. (Firefox browser) in the td,th nested div,p, etc. using the above mentioned methods to deal with Firefox
Run Code Box
Finally, the probability of this phenomenon is very small, but can not exclude users of the spoof.

Here is the effect of the example mentioned

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "
<html xmlns=" "
<head>
< Meta http-equiv= "Content-type" content= "HTML; charset=gb2312 "/>
<title> character wrapping </title>
<style type=" Text/css "
Table,td,th,div { BORDER:1PX Green solid;
Code {font-family: "Courier New", Courier, monospace;}
</style>
</head>
<body>
<h1><code>div</code></h1>
<h1><code>all white-space:normal;</code></h1>
<div style= white-space:normal; width : 200px; >wordwrap e.g. occurs in a TD element, super-delegates its WIDTH attribute set to a value smaller than , Evan If the NoWrap is set to true. Therefore, the WIDTH attribute takes precedence over the NoWrap property in this scenario</div>

<h1><code>ie word-wrap:break-word </code></h1>
<div style= Word-wrap:break-word ; width:200px; " >abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111</div>
<h1><code>ie Word-break: Break-all;</code></h1>
<div style= "word-break:break-all;width:200px;" >abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111</div>

<h1><code>Firefox/word-break:break-all; overflow:auto;</code></h1>
<div style= Word-break:break-all; width:200px; Overflow:auto; " >abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111</div>
<h1><code>table</code ></h1>
<h1><code>table-layout:fixed;</code></h1>
<table style= Table-layout:fixed "width="
<tr>
<td> Abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss</td>
</tr>
</table>
<h1> <code>table-layout:fixed; Word-break:break-all; Word-wrap:break-word </code></h1>
<table width= style= "table-layout:fixed";
<tr>
<td width= "mainly style=" word-break:break-all; ">abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss</td>
<td style=" Word-wrap:break-word; >abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss</td>
</tr>
</TABLE>
<H1><CODE>FF table-layout:fixed; Overflow:hidden;</code></h1>
<table style= "table-layout:fixed" width= "<tr>"

<td width= "mainly style=" word-break:break-all; ">abcdefghigklmnopqrstuvwxyz1234567890</td>
<td width=" 75% "style=" Word-wrap:break-word: Hidden; ">abcdefghigklmnopqrstuvwxyz1234567890</td>
</tr>
</table>
</body>
< /html>

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.