we all know. Text can be wrapped automatically when you write a Web page. But one of the things that makes us very upset is that English is often not automatically wrapped. Especially in English. Sometimes we use CSS to restrict the properties of a table. Like Overflow:hidden, But this attribute does not do a good job for what we want. Here we will introduce the use of CSS to achieve word wrapping in several ways. For your reference:
for Div
1, (ie browser) white-space:normal; Word-break:break-all, where the former is to follow the standard.
#wrap {white-space:normal; width:200px;}
or
.
#wrap {word-break:break-all;width:200px}
<div >ddd1111111111111111111111111111111111</div>
Effect: You can implement line wrapping
2, (Firefox browser) white-space:normal; Word-break:break-all;overflow:hidden, the same FF also does not have a good implementation method, can only hide or add scroll bar, of course, without the scroll bar effect better! #wrap {white-space:normal; width:200px; overflow:auto;}
or
.
#wrap {word-break:break-all;width:200px; overflow:auto;}
<div >ddd1111111111111111111111111111111111111111</div>
effect: Container normal, content hidden
for
1, (ie browser) using the style table-layout:fixed;
The following are the referenced content:
<style>
. tb{table-layout:fixed}
</style>
<table width= ">
"
<tr>
<td>www.qpsh.com www.qpsh.com www.qpsh.com
</td>
</tr>
</table>
Effect: You can change lines
2, (ie browser) using styles table-layout:fixed and nowrap
The following are the referenced content:
<style>
. TB {table-layout:fixed}
</style>
<table width= ">
"
<tr>
<TD nowrap>abcdefghigklmnopqrstuvwxyz 1234567890
</td>
</tr>
</table>
Effect: You can change lines
3, (ie browser) using a percentage fixed TD size case use style table-layout:fixed and nowrap
The following are the referenced content:
<style>
. tb{table-layout:fixed}
</style>
<table width=80>
<tr>
<td width=25% nowrap>abcdefghigklmnopqrstuvwxyz 1234567890
</td>
<td nowrap>abcdefghigklmnopqrstuvwxyz 1234567890
</td>
</tr>
</table>
effect: Two TD all normal line change
4, (Firefox browser) uses the style table-layout:fixed and nowrap using a percentage fixed TD size, and uses Div
The following are the referenced content:
<style>
. TB {table-layout:fixed}
. td {Overflow:hidden;}
</style> <table width=80>
<tr>
<td width=25% nowrap>
<div>abcdefghigklmnopqrstuvwxyz 1234567890</div>
</td>
<TD nowrap>
<div>abcdefghigklmnopqrstuvwxyz 1234567890</div>
</td>
</tr>
</table>
here the cell width must be defined in percent
effect: normal display, but can not wrap (note: Under FF has not been able to make the container content of a good way to change lines, can only use overflow will be more content to hide, so as not to affect the overall effect)