Using width property for table data cells to change the look of table
<table id='tab' border='2'>
<tr><td width="33%">col 1,1</td><td width="33%">col 1,2</td><td width="33%">col 1,3</td></tr>
<tr><td width="50%">col 2,1</td><td width="50%">col 2,2</td></tr>
<tr><td width="33%">col 3,1</td><开发者_如何转开发td width="33%">col 3,2</td><td width="33%">col 3,3</td></tr>
</table>
Hello I am trying to get all columns in a order, so I am varying the widths of different cells to achieve the requirement. Now the problem is, the table is taking 50% as the table cell width directly and everything gets distorted. How do I work with this?
My html code is being stripped off or rendered even if I use the code tags, how do I insert my HTML code?
The problem is the second row, it should be
<table id='tab' border='2'>
<tr><td width="33%">col 1,1</td><td width="33%">col 1,2</td><td width="33%">col 1,3</td></tr>
<tr><td width="33%">col 2,1</td><td width="33%">col 2,2</td></tr>
<tr><td width="33%">col 3,1</td><td width="33%">col 3,2</td><td width="33%">col 3,3</td></tr>
</table>
Or
<table id='tab' border='2'>
<tr><td width="33%">col 1,1</td><td width="33%">col 1,2</td><td width="33%">col 1,3</td></tr>
<tr><td width="33%">col 2,1</td><td width="66%" colspan="2">col 2,2</td></tr>
<tr><td width="33%">col 3,1</td><td width="33%">col 3,2</td><td width="33%">col 3,3</td></tr>
</table>
because your second row has only 2 columns and the others have 3?
I am interpreting that you want 3 rows, something like this:
| 1,1 | 1,2 | 1,3 |
| 2,1 | 2,2 |
| 3,1 | 3,2 | 3,3 |
Based on that expectation, the only way I know to do this without a nested table is to pretend that you have 4 columns and add a colspan=2
argument to cells (1,2), (2,1), (2,2), and (3,2) as in the following:
<table id='tab' border='2'>
<tr><td width="33%">col 1,1</td><td colspan=2 width="33%">col 1,2</td><td width="33%">col 1,3</td></tr>
<tr><td colspan=2 width="50%">col 2,1</td><td colspan=2 width="50%">col 2,2</td></tr>
<tr><td width="33%">col 3,1</td><td colspan=2 width="33%">col 3,2</td><td width="33%">col 3,3</td></tr>
</table>
To help learn about the various effects that different parameter values have, I recommend the w3schools editable "Try it" pages.
精彩评论