Solution to invalid table width setting
After setting the table-layer: fixed style for the table, you can find that one row in the table has been merged. The column widths of other rows that have not been merged are averaged, and the setting of the column width is invalid.
See the following code:
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br/> <HTML xmlns = "http://www.w3.org/1999/xhtml"> <br/> <pead> <br/> <meta http-equiv = "Content-Type" content = "text/html; charset = gb2312 "/> <br/> <title> test </title> <br/> </pead> <br/> <body style =" width: 98%; height: 100%; margin-left: 0px; margin-top: 0px "> <br/> <Table Style =" border: 1px solid # 0000ff; Table-layout: fixed; width: 100%; Height: 90%; "Border =" 1 "> <br/> <tbody> <br/> <tr> <br/> <TD colspan =" 3 "> DD </TD> <br /> </tr> <br/> <TD style = "width: 60% "> usage </TD> <br/> <TD style =" width: 20% "> ddddd </TD> <br/> <TD style =" width: 20% "> cccccccc </TD> <br/> </tr> </P> <p> <tr> <br/> <TD> & nbsp; </TD> <br/> <TD> & nbsp; </TD> <br/> </tr> <br/> <TD> & nbsp; </TD> <br/> <TD> & nbsp; </TD> <br/> </tr> <br/> </tbody> <br/> </table> <br/> </body> <br/> </ptml>
Tip: you can modify some code before running
If you remove the merged rows from the table, the table is displayed normally.
Cause:
Table-layout: fixed table. The column width is determined by the first row. The width specified later is ignored.
The first row is merged, so the width of each column is evenly divided.
Solution:
Add
<Col style = "width: 60%"/>
<Col style = "width: 20%"/>
<Col style = "width: 20%"/>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br/> <HTML xmlns = "http://www.w3.org/1999/xhtml"> <br/> <pead> <br/> <meta http-equiv = "Content-Type" content = "text/html; charset = gb2312 "/> <br/> <title> test </title> <br/> </pead> <br/> <body style =" width: 98%; height: 100%; margin-left: 0px; margin-top: 0px "> <br/> <Table Style =" border: 1px solid # 0000ff; Table-layout: fixed; width: 100%; Height: 90%; "border =" 1 "> <br/> <Col style =" width: 60% "/> <br/> <Col style =" width: 20% "/> <br/> <Col style =" width: 20% "/> <br/> <tbody> <br/> <tr> <br/> <TD colspan =" 3 "> DD </TD> <br/> </tr> <br/> <TD style = "width: 60% "> usage </TD> <br/> <TD style =" width: 20% "> ddddd </TD> <br/> <TD style =" width: 20% "> cccccccc </TD> <br/> </tr> </P> <p> <tr> <br/> <TD> & nbsp; </TD> <br/> <TD> & nbsp; </TD> <br/> </tr> <br/> <TD> & nbsp; </TD> <br/> <TD> & nbsp; </TD> <br/> </tr> <br/> </tbody> <br/> </table> <br/> </body> <br/> </ptml>
Tip: you can modify some code before running