If you want a table to be fixed in size, the text inside will be forcibly wrapped (especially when a long string of English text is separated by spaces ), the style: Table-layout: fixed. However, there will be some problems in Firefox. Refer to some Gmail practices and perform several tests to find a solution.
If you want a table to be fixed in size, the text inside will be forcibly wrapped (especially when a long string of English text is separated by spaces ), the style: Table-layout: fixed. However, there will be some problems in Firefox. Refer to some Gmail practices and perform several tests to find a solution.
Example 1: (IE browser) General situation
<Table border = 1 width = 80>
<Tr>
<TD> abcdefghigklmnopqrstuvwxyz 1234567890
</TD>
</Tr>
</Table>
Effect:
We can see that width = 80 does not work, and the table is opened by characters.
Example 2: (IE browser) use the style table-layout: fixed
<Style>
. TBL {table-layout: Fixed}
</Style>
<Table class = TBL border = 1 width = 80>
<Tr>
<TD> abcdefghigklmnopqrstuvwxyz 1234567890
</TD>
</Tr>
</Table>
Effect:
Width = 80 takes effect, but the table line breaks.
Example 3: (IE browser) use the style table-layout: fixed and nowrap
<Style>
. TBL {table-layout: Fixed}
</Style>
<Table class = TBL border = 1 width = 80>
<Tr>
<TD nowrap> abcdefghigklmnopqrstuvwxyz 1234567890
</TD>
</Tr>
</Table>
Effect:
Width = 80 takes effect, and line feed is also killed.
Example 4: (IE browser) use the style table-layout: fixed and nowrap when the value is fixed to the TD size.
<Style>
. TBL {table-layout: Fixed}
</Style>
<Table class = TBL border = 1 width = 80>
<Tr>
<TD width = 20 nowrap> abcdefghigklmnopqrstuvwxyz 1234567890
</TD>
<TD nowrap> abcdefghigklmnopqrstuvwxyz 1234567890
</TD>
</Tr>
</Table>
Effect:
Unfortunately, nowrap of the first td does not work.
Example 5: (IE browser) use the style table-layout: fixed and nowrap when the percentage is fixed to the TD size.
<Style>
. TBL {table-layout: Fixed}
</Style>
<Table class = TBL border = 1 width = 80>
<Tr>
<TD width = 25% nowrap> abcdefghigklmnopqrstuvwxyz 1234567890
</TD>
<TD nowrap> abcdefghigklmnopqrstuvwxyz 1234567890
</TD>
</Tr>
</Table>
Effect:
Change to percentage, and finally get it done
Example 6: (Firefox browser) use the style table-layout: fixed and nowrap when the percentage of TD size is fixed
Effect:
Put Example 5 under Firefox, and FT again
Example 7: (Firefox browser) use the style table-layout: fixed and nowrap when the percentage is fixed to the TD size, and use the DIV
<Style>
. TBL {table-layout: Fixed}
. TD {overflow: hidden ;}
</Style>
<Table class = TBL border = 1 width = 80>
<Tr>
<TD width = 25% class = TD nowrap>
<Div> abcdefghigklmnopqrstuvwxyz 1234567890 </div>
</TD>
<TD class = TD nowrap>
<Div> abcdefghigklmnopqrstuvwxyz 1234567890 </div>
</TD>
</Tr>
</Table>
Effect:
The world is finally peaceful
Example 8: (Firefox browser) use the style table-layout: fixed and nowrap when the value is fixed to the TD size, and use the DIV
<Style>
. TBL {table-layout: Fixed}
. TD {overflow: hidden ;}
</Style>
<Table class = TBL border = 1 width = 80>
<Tr>
<TD width = 20 class = TD nowrap>
<Div> abcdefghigklmnopqrstuvwxyz 1234567890 </div>
</TD>
<TD class = TD nowrap>
<Div> abcdefghigklmnopqrstuvwxyz 1234567890 </div>
</TD>
</Tr>
</Table>
Effect:
Nowrap does not work anymore.
In the end, Example 7 is a solution that can perfectly solve the page force Line Break Problem in IE and Firefox.