I would like for top 4 elements to stretch across the top, and bottom two to also look like they belong to the same table, stretch and not be so squeezed. Can I accomplish this without adding empty <td>s?
This is how it looks like right now:
http://www.w3schools.com/code/tryit.asp?filename=F0OOEL3HH55Y
My code:
<table cellspacing="2" cellpadding="2" width="650" border="0">
<tr>
<td height="8" class="header" width="300">Weight Per Book (lb.)</td>
<td height="8" class="header" width="300">Cost per Book</td>
<td height="8" class="header" width="200">Quantity for whole order</td>
<td height="8" class="header" width="400">Capability Complexity Level For TO</td>
</tr>
<tr>
<td height="16">2.0</td>
<td height="16">0.00</td>
<td height="16">0</td>
<td height="16">4</td>
</tr>
<tr valign="bottom">
<td class="header">Distribute ID Order to Home Plant</td>
<td class="header">Distribute All OTR's to Home Plant</td>
</tr>
<tr>
<td>No</td>
<td>No</td>
</tr>
</table>
You can use the colspan attribute to do that. This attribute define the number of columns a particular cell should span.
Here is an example:
<table cellspacing="2" cellpadding="2" width="650" border="0">
<tr>
<th colspan="4">Production</th>
</tr>
<tr>
<td height="8" class="header" width="300">Weight Per Book (lb.)</td>
<td height="8" class="header" width="300">Cost per Book</td>
<td height="8" class="header" width="200">Quantity for whole order</td>
<td height="8" class="header" width="400">Capability Complexity Level For TO</td>
</tr>
<tr>
<td height="16">2.0</td>
<td height="16">0.00</td>
<td height="16">0</td>
<td height="16">4</td>
</tr>
<tr valign="bottom">
<td colspan="2" class="header">Distribute ID Order to Home Plant</td>
<td colspan="2" class="header">Distribute All OTR's to Home Plant</td>
</tr>
<tr>
<td colspan="2">No</td>
<td colspan="2">No</td>
</tr>
</table>
Hope this helps!
Related
I have one table shown on screen with menu layout.
While menu is not collapsed the table is showing perfectly on screen like the below image.
But once I Collapse the Menu toggle button the table design is getting out of screen like below image. Last 3 columns were out of screen body.
Below is the code for table I am using.
<table width="100%" border="1" cellpadding="1" cellspacing="2" bordercolor="#999999">
<tbody>
<tr>
<td height="24" width="20%">Customer</td>
<td width="15%">Purchase</td>
<td width="15%">Branch</td>
<td width="15%">Status</td>
<td width="15%">PO Issue date</td>
<td width="15%">Delivery Date</td>
<td width="15%">Return Date</td>
<td width="15%">Approved By</td>
<td width="15%">Equipment Recovery</td>
<td width="15%">Labor Recovery</td>
<td width="15%">Shipping Recovery</td>
<td width="15%">Purchase Recovery</td>
<td width="15%">Other Recovery</td>
<td bgcolor="#E6E6E6"><strong>Total</strong></td>
<td>Equipment Rental</td>
<td>Labor</td>
<td>Shipping</td>
<td>Equipment Purchase</td>
<td>Other</td>
<td>Tax</td>
<td>Loss Code</td>
<td nowrap="nowrap" width="100%">Internal Notes</td>
</tr>
<tr>
<td height="24" colspan="13">
<div align="right"><strong>TOTALS</strong></div>
</td>
<td bgcolor="#E6E6E6">$0.00</td>
<td>$0.00</td>
<td>$0.00</td>
<td>$0.00</td>
<td>$0.00</td>
<td>$0.00</td>
<td>$0.00</td>
<td colspan="2"></td>
</tr>
</tbody>
</table>
Can anybody have look and let me know how I can overcome it.
Just like how in the image I linked "tache1" and "tache2" in the 4th row are splitting "Mercredi" in two
<table width="400" border="2" cellspacing="1" cellpadding="1">
<tr>
<th width="15%" rowspan="2">Equipes</th>
<th width="70%" colspan="5">Janvier</th>
<td width="15%" rowspan="2"></td>
</tr>
<tr>
<th>Lundi</th>
<th>Mardi</th>
<th>Mercredi</th>
<th>Jeudi</th>
<th>Vendredi</th>
</tr>
<tr>
<td rowspan="2">Equipe1</td>
<td colspan="3">tache1</td>
<td colspan="2">tache2</td>
<td rowspan="2">Semaine1</td>
</tr>
<tr>
<td colspan="2">tache1</td>
<td colspan="3">tache2</td>
</tr>
</table>
Use 6 colspan instead of 5 in <th width="70%" colspan="6">Janvier</th> Then use 2 colspan for Mercredi like this <th colspan="2">Mercredi</th> Then use 3 colspan for each tache like this
<td colspan="3">tache1</td>
<td colspan="3">tache2</td>
Also In your setup, Equip1 is taking 2 rows but its content to the right take only 1 row.
so use rowspan"1" for both Equipe1 and 2.
<table width="600" border="2" cellspacing="1" cellpadding="1">
<tr>
<th width="15%" rowspan="2">Equipes</th>
<th width="70%" colspan="6">Janvier</th>
<td width="15%" rowspan="2"></td>
</tr>
<tr>
<th>Lundi</th>
<th>Mardi</th>
<th colspan="2">Mercredi</th>
<th>Jeudi</th>
<th>Vendredi</th>
</tr>
<tr>
<td rowspan="1">Equipe1</td>
<td colspan="3">tache1</td>
<td colspan="3">tache2</td>
<td rowspan="2">Semaine1</td>
</tr>
<tr>
<td rowspan="1">Equipe2</td>
<td colspan="3">tache1</td>
<td colspan="3">tache2</td>
</tr>
</table>
I am creating a table inside another table. I have divided the columns to be the exact same ratio as the outer table. However, the columns are not aligned with outer table columns. Can anyone tell me what I am missing?
<html>
<div style="overflow:scroll;height:140px;width:100%;overflow:auto" style="background-color:black">
<table width="100%" style="padding:0; margin:0;" cellpadding="0">
<tr class="tbl_header" cellpadding="0">
<td width="3%">test1</td>
<td width="7%">test2</td>
<td width="3%">test3</td>
<td width="12%">test4</td>
<td width="7%">test5</td>
<td width="10%"test6</td>
<td width="7%">test7</td>
</tr>
<tr style="background-color:yellow">
<td colspan="7" style="background-color:yellow">
<div style="overflow:scroll;height:110px;width:100%;overflow:auto;border:none;background-color:green">
<table width="100%" style="border:none;background-color:red" cellpadding="0">
<tr class="even">
<td width="3%">2</td>
<td width="7%" class="tdAlign">Testing </td>
<td width="3%" class="tdAlign">Testing </td>
<td width="12%" class="tdAlign">Testing Testing Testing</td>
<td width="7%">Testing_1</td>
<td width="10%">Testing_2</td>
<td width="7%">Testing_3</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
</html>
When I inspect the table with chromes web kit. I see that the tables with 3% then they are supposed to be, because of the text length. U can fix this by adding table-layout: fixed to both your <table> elements.
If U want to use a table header I suggest using <th> (see here)
<html>
<div style="overflow:scroll;height:140px;width:100%;overflow:auto" style="background-color:black">
<table width="100%" style="padding:0; margin:0;" cellpadding="0">
<tr class="tbl_header" cellpadding="0">
<td width="3%">test1</td>
<td width="7%">test2</td>
<td width="3%">test3</td>
<td width="12%">test4</td>
<td width="7%">test5</td>
<td width="10%">test6</td>
<td width="7%">test7</td>
</tr>
<tr style="background-color:yellow">
<td colspan="7" style="background-color:yellow">
<div style="overflow:scroll;height:110px;width:100%;overflow:auto;border:none;background-color:green">
<table width="100%" style="border:none;background-color:red" cellpadding="0">
<tr class="even">
<td width="3%">2</td>
<td width="7%" class="tdAlign">Testing </td>
<td width="3%" class="tdAlign">Testing </td>
<td width="12%" class="tdAlign">Testing Testing Testing</td>
<td width="7%">Testing_1</td>
<td width="10%">Testing_2</td>
<td width="7%">Testing_3</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
</html>
Looks like you missed a closing tag for a <TD>(<td width="10%">test6</td>). Hope this helps. Let me know
My <td> width seems to be ignored for some reason related to the tabledatas above it since if I remove all rows except the row that seems to be having the issue, it then works fine.
I am thinking it has something to do with the colspans.
I saw this answer colspan width issue which talks about how you basically need to imagine there are invisible cells in your table, but I was already doing that, but maybe I am doing it wrong?
Here is the html
<table border="1" cellspacing="0" cellpadding="0" width="600">
<tr>
<td id="IX991PI1" rowspan="1" colspan="3" width="412" height="81" ></td>
<td id="OW6DMR2F" rowspan="1" colspan="1" width="188" height="81" ></td>
</tr>
<tr>
<td id="RU5UW85Z" rowspan="1" colspan="3" width="412" height="66" ></td>
<td id="RGPQDOYK" rowspan="2" colspan="1" width="188" height="204" ></td>
</tr>
<tr>
<td id="67JXVSFB" rowspan="1" colspan="3" width="412" height="138" ></td>
</tr>
<tr>
<td id="AB6FD7D5" rowspan="1" colspan="1" width="145" height="67" ></td>
<td id="RU0G6BL8" rowspan="1" colspan="3" width="455" height="67" ></td>
</tr>
<tr>
<td id="0B0D4ZVN" rowspan="1" colspan="4" width="600" height="29" ></td>
</tr>
<!-- the problematic row -->
<tr>
<td id="V4GHN5BW" rowspan="1" colspan="2" width="242" height="100" ></td>
<td id="CK3PB3OT" rowspan="1" colspan="2" width="358" height="100" ></td>
</tr>
</table>
Here is an image of the table as it is wrong and how it should look
As far as I can see, all widths add up to 600, and all colspans have the right amount keeping the invisible cells in mind (total of 4 cols). In fact, the problematic row is what's making there be 4 cols, so I would expect it to have full control on where that invisible line goes that cuts all the above and below rows.
I can't think of anything else that could be causing the issue other than the colspans, so I must be doing something wrong.
Edit- Also, this is for emails, so I am limited on css and such...
Edit- I was using google chrome and after trying it on firefox there seems to be no issue?
However, I then added more rows to the table to see if something won't work in both browsers, and I have quickly ran into that problem.
The bottom 4 rows are where the problems start (the first is the problematic row from above). Even putting those rows into their own table still has issues.
<table border="1" cellspacing="0" cellpadding="0" width="600" >
<tr>
<td id="5DPKU34O" rowspan="1" colspan="4" width="412" height="81" ></td>
<td id="XHK07WYR" rowspan="1" colspan="1" width="188" height="81" ></td>
</tr>
<tr>
<td id="5IP7MCTF" rowspan="1" colspan="4" width="412" height="66" ></td>
<td id="WO4JPVJ6" rowspan="2" colspan="1" width="188" height="204" ></td>
</tr>
<tr>
<td id="JLCGN4YY" rowspan="1" colspan="4" width="412" height="138" ></td>
</tr>
<tr>
<td id="RX6Q81VD" rowspan="1" colspan="1" width="145" height="67" ></td>
<td id="6YNA6379" rowspan="1" colspan="4" width="455" height="67" ></td>
</tr>
<tr>
<td id="4DIOQA09" rowspan="1" colspan="5" width="600" height="29" ></td>
</tr>
<!-- problem starts here -->
<tr>
<td id="0X3RX651" rowspan="1" colspan="2" width="242" height="50" ></td>
<td id="L1TLGZIX" rowspan="2" colspan="3" width="358" height="220" ></td>
</tr>
<tr>
<td id="U1BAFJFK" rowspan="1" colspan="2" width="242" height="170" ></td>
</tr>
<tr>
<td id="VPM6G120" rowspan="1" colspan="3" width="380" height="192" ></td>
<td id="LF6WV55J" rowspan="1" colspan="2" width="220" height="192" ></td>
</tr>
<tr>
<td id="DW95YX3T" rowspan="1" colspan="5" width="600" height="16" ></td>
</tr>
</table>
Here is an image illustrating the issue in Firefox and Chrome.
To set the widths of table columns that have colspans, the most reliable method is to set the width for each column explicitly using <col> elements.
That way, the browser will know from the start which column has which width, and also how many columns there actually are!
This method also has the advantage that you won't need to specify the width in each and every table cell, so it's more efficient in terms of bytes, and less error-prone in terms of typos.
<table border="1" cellspacing="0" cellpadding="0">
<col width="145"><col width="97"><col width="170"><col width="188">
<tr>
<td id="IX991PI1" colspan="3" height="81"></td>
<td id="OW6DMR2F" height="81"></td>
</tr>
<tr>
<td id="RU5UW85Z" colspan="3" height="66"></td>
<td id="RGPQDOYK" rowspan="2" height="204"></td>
</tr>
<tr>
<td id="67JXVSFB" colspan="3" height="138"></td>
</tr>
<tr>
<td id="AB6FD7D5" height="67"></td>
<td id="RU0G6BL8" colspan="3" height="67"></td>
</tr>
<tr>
<td id="0B0D4ZVN" colspan="4" height="29"></td>
</tr>
<!-- the no longer problematic row -->
<tr>
<td id="V4GHN5BW" colspan="2" height="100"></td>
<td id="CK3PB3OT" colspan="2" height="100"></td>
</tr>
</table>
I also took the liberty of removing all colspan=1 and rowspan=1 attributes, since those are not necessary. And the width attribute on the table itself was also superfluous.
Tested in Chrome and Mozilla, and it looks good in Thunderbird too.
Try to remove the width in your td in row problematic tag. This sets the maximum width for its child.
<!-- the problematic row -->
<tr>
<td id="V4GHN5BW" rowspan="1" colspan="2" height="100" ></td>
<td id="CK3PB3OT" rowspan="1" colspan="2" height="100" ></td>
</tr>
<html>
<body>
<table align="left" border="0" cellpadding="1" cellspacing="1" style="width: 1000px;">
<tbody>
<tr>
<td width="300">Hanrathsingel 14</td>
<td width="300">Home</td>
<td width="400" height="100%">This one has to take the full height of the table</td>
</tr>
<tr>
<td width="300">1252 AE Laren</td>
<td width="300">Wie zijn wij</td>
</tr>
<tr>
<td width="300">T. 035-6231419</td>
<td width="300">Informatie</td>
</tr>
<tr>
<td width="300">M. 06-21700357</td>
<td width="300">Algemene Voorwaarden</td>
</tr>
<tr>
<td width="300">laren#qualitysites4all.com</td>
<td width="300">Contact</td>
</tr>
</tbody>
</table>
</body>
</html>
How do I get the column to be 100% of the table height but the other columns must keep their height?
Because I want to put a widget in there but I have to work in my boss his cms and I am not allowed to make new divs :(
Try rowspan:
<table align="left" border="0" cellpadding="1" cellspacing="1" style="width: 1000px;">
<tbody>
<tr>
<td width="300">Hanrathsingel 14</td>
<td width="300">Home</td>
<td width="400" rowspan="5">This one has to take the full height of the table</td>
</tr>
<tr>
<td width="300">1252 AE Laren</td>
<td width="300">Wie zijn wij</td>
</tr>
<tr>
<td width="300">T. 035-6231419</td>
<td width="300">Informatie</td>
</tr>
<tr>
<td width="300">M. 06-21700357</td>
<td width="300">Algemene Voorwaarden</td>
</tr>
<tr>
<td width="300">laren#qualitysites4all.com</td>
<td width="300">Contact</td>
</tr>
</tbody>
</table>
Example
JSFiddle Example
Use rowspan="5" in that TD.
Rowspan attribute, tells your element to "get the height" of 5 rows in this case.
If you have dinamic content remember to update this value to the actual number of rows of your table.