I am working with a bootstrap table, which contains in the right corner a table with rowspan = "2", then it has 2 rows, and then at the other end another rowspan = "2", looking like this:
The problem I'm having is that I can't "shrink" the width of the table where the image is, that is, the first column, I tried with col-1, with colspan = "1" but so far I can't find a solution, could you help me ?, the TOTAL WIDTH OF THE TABLE WHERE THE IMAGE IS, SHOULD BE THE SAME ROWSPAN = "1".
This is the code:
<tr>
<td rowspan="2" colspan="1">
<img src="IMAGE">
</td>
<td class="col-10">
PRODUCT NAME
</td>
<td rowspan="2" colspan="1">$PRICE</td>
</tr>
<tr>
<td>
<span>DESCRIPCION</strong></span>
</td>
</tr>
If you need a set width for image row, you can use width="...px" into <td width="..px">
I try make a example like this
table {
border-collapse: collapse;
}
table,
tr,
th,
td {
border: 1px solid #000;
}
th {
padding: 1ex;
background: #ccc;
}
td {
padding: 1ex;
}
.divide td {
border-top: 3px solid;
}
<table>
<tr>
<td rowspan="2" colspan="1" width="200px">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/ef/Stack_Overflow_icon.svg/768px-Stack_Overflow_icon.svg.png" width="50px">
</td>
<td class="col-10">
PRODUCT NAME
</td>
<td rowspan="2" colspan="1">$PRICE</td>
</tr>
<tr>
<td>
<span>DESCRIPCION</strong></span>
</td>
</tr>
</table>
<table>
<tr>
<td rowspan="2" colspan="1" width="150px">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/ef/Stack_Overflow_icon.svg/768px-Stack_Overflow_icon.svg.png" width="50px">
</td>
<td class="col-10">
PRODUCT NAME
</td>
<td rowspan="2" colspan="1">$PRICE</td>
</tr>
<tr>
<td>
<span>DESCRIPCION</strong></span>
</td>
</tr>
</table>
<table>
<tr>
<td rowspan="2" colspan="1" width="100px">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/ef/Stack_Overflow_icon.svg/768px-Stack_Overflow_icon.svg.png" width="50px">
</td>
<td class="col-10">
PRODUCT NAME
</td>
<td rowspan="2" colspan="1">$PRICE</td>
</tr>
<tr>
<td>
<span>DESCRIPCION</strong></span>
</td>
</tr>
</table>
<br>
<br>
<table>
<tr>
<th>head</th>
<th>title</th>
<th>title</th>
<th>title</th>
<th></th>
</tr>
<tr>
<td>
<input type="checkbox">
</td>
<td>content</td>
<td>content</td>
<td>content</td>
<td rowspan="2">white</td>
</tr>
<tr>
<td colspan="4">
lorem ipsum
</td>
</tr>
<tr class="divide">
<td>
<input type="checkbox">
</td>
<td>content</td>
<td>content</td>
<td>content</td>
<td rowspan="2">gray</td>
</tr>
<tr>
<td colspan="4">
lorem ipsum
</td>
</tr>
<tr class="divide">
<td>
<input type="checkbox">
</td>
<td>content</td>
<td>content</td>
<td>content</td>
<td>white</td>
</tr>
<tr class="divide">
<td>
<input type="checkbox">
</td>
<td>content</td>
<td>content</td>
<td>content</td>
<td rowspan="2">gray</td>
</tr>
<tr>
<td colspan="4">
lorem ipsum
</td>
</tr>
</table>
Related
How to build this table in html ??
I want to make table using rowspan and colspan ?
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"/>
<table class="table table-bordered">
<thead>
<th>Subject</th>
<th>Result</th>
</thead>
<tbody>
<tr>
<td>Science</td>
<td>Physics</td>
<td>Chemistry</td>
<td>Other Science</td>
<td>Math</td>
<td>English</td>
</tr>
</tbody>
</table>
You can learn about <table> tags at MDN
You can do this:
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" />
<table class="table table-bordered">
<thead>
<tr>
<th colspan="2">Subject</th>
<th>Result</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="2">Science</td>
<td>Physics</td>
<td>A</td>
</tr>
<tr>
<td>Chemistry</td>
<td>A</td>
</tr>
<tr>
<td rowspan="2">Other Science</td>
<td>Biology</td>
<td>B</td>
</tr>
<tr>
<td>Geography</td>
<td>A</td>
</tr>
<tr>
<td colspan="2">Math</td>
<td>A+</td>
</tr>
<tr>
<td colspan="2">English</td>
<td>A+</td>
</tr>
</tbody>
</table>
This is set-up with colspan and rowspan
table {
border-collapse: collapse;
}
table,
tr,
th,
td {
border: 1px solid #000;
}
th {
padding: 1ex;
background: #ccc;
}
td {
padding: 1ex;
}
.divide td {
border-top: 3px solid;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" />
<table class="table table-bordered">
<thead>
<th colspan="2">Subject</th>
<th>Result</th>
</thead>
<tbody>
<tr>
<td rowspan="2" colspan="1" width="100px">
SCIENCE
</td>
<td>
Physics
</td>
<td>A</td>
</tr>
<tr>
<td>
<span>Chemistry</span>
</td>
<td colspan="1">A</td>
</tr>
<tr>
<td rowspan="2" colspan="1" width="100px">
SCIENCE
</td>
<td>
Physics
</td>
<td>A</td>
</tr>
<tr>
<td>
<span>Chemistry</span>
</td>
<td colspan="1">A</td>
</tr>
<tr>
<td colspan="2">
SCIENCE
</td>
<td>A</td>
</tr>
<tr>
<td colspan="2">
SCIENCE
</td>
<td>A</td>
</tr>
</tbody>
</table>
<br>
<br>
<table>
<tr>
<th>head</th>
<th>title</th>
<th>title</th>
<th>title</th>
<th></th>
</tr>
<tr>
<td>
<input type="checkbox">
</td>
<td>content</td>
<td>content</td>
<td>content</td>
<td rowspan="2">white</td>
</tr>
<tr>
<td colspan="4">
lorem ipsum
</td>
</tr>
<tr class="divide">
<td>
<input type="checkbox">
</td>
<td>content</td>
<td>content</td>
<td>content</td>
<td rowspan="2">gray</td>
</tr>
<tr>
<td colspan="4">
lorem ipsum
</td>
</tr>
<tr class="divide">
<td>
<input type="checkbox">
</td>
<td>content</td>
<td>content</td>
<td>content</td>
<td>white</td>
</tr>
<tr class="divide">
<td>
<input type="checkbox">
</td>
<td>content</td>
<td>content</td>
<td>content</td>
<td rowspan="2">gray</td>
</tr>
<tr>
<td colspan="4">
lorem ipsum
</td>
</tr>
</table>
I want to make this template with html tables,
This is my html code
<table>
<tr>
<td>data</td>
<td>data</td>
<td>data</td>
<td>data</td>
<td>data</td>
<td>data</td>
<td>
<table>
<tr>
<td>data</td>
<td>data</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td>data</td>
<td>data</td>
</tr>
</table>
</td>
<td>data</td>
</tr>
</table>
But it is not giving me the right format like the image above. How can i do it with table?
For the template as per the reference, you need to use this code
table { border: 1px solid #000; border-collapse: collapse; }
table th { padding: 5px 10px; border: 1px solid #000; }
table td { padding: 5px 10px; border-left: 1px solid #000; border-right: 1px solid #000; }
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<th rowspan="2">Sr. No.</th>
<th rowspan="2">Description of Goods</th>
<th rowspan="2">HSN</th>
<th rowspan="2">Qty.</th>
<th rowspan="2">Unit</th>
<th rowspan="2">Rate (per item)</th>
<th rowspan="2">Total</th>
<th rowspan="2">Discount</th>
<th rowspan="2">Taxable Value</th>
<th colspan="2" align="center">CGST</th>
<th colspan="2" align="center">SGST</th>
<th colspan="2" align="center">IGST</th>
</tr>
<tr>
<th>Rate</th>
<th>Amt.</th>
<th>Rate</th>
<th>Amt.</th>
<th>Rate</th>
<th>Amt.</th>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
Several ways to do this. You could use a table in a td or you could make use of colspan and rowspan like in my example.
Good luck.
table {
border-collapse: collapse;
height: 100px;
font-size: 10px;
text-align: center;
}
td {
padding: 5px;
border: solid 1px black;
}
<table>
<tr>
<td rowspan=2>Sr.No</td>
<td rowspan=2>Description of Goods</td>
<td rowspan=2>HSN</td>
<td rowspan=2>Qty.</td>
<td rowspan=2>Unit</td>
<td rowspan=2>Rate(per item)</td>
<td rowspan=2>Total</td>
<td rowspan=2>Discount</td>
<td rowspan=2>Taxable value</td>
<td colspan=2>CGST</td>
<td colspan=2>SGST</td>
<td colspan=2>IGST</td>
</tr>
<tr>
<td>Rate</td>
<td>Amt.</td>
<td>Rate</td>
<td>Amt.</td>
<td>Rate</td>
<td>Amt.</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
It is called as Table with Irregular Headers
You have to use
<th colspan="2" scope="colgroup">MainHeadername</th>
for main Header and
<th scope="col">SubHeaderName</th>
for Sub Headers
This Reference will be Helpful for further clarifications
https://www.w3.org/WAI/tutorials/tables/irregular/
You can do this using colspan:
table, th, td {
border: 1px solid black;
}
<table>
<tr>
<th>65</th>
<th>80</th>
<th colspan="2">40</th>
<th colspan="2">20</th>
</tr>
<tr>
<th>Men</th>
<th>Women</th>
<th>Men</th>
<th>Women</th>
<th>Men</th>
<th>Women</th>
</tr>
<tr>
<td>82</td>
<td>85</td>
<td>78</td>
<td>82</td>
<td>77</td>
<td>81</td>
</tr>
</table>
I created an HTML page and I used table, but i have a problem in first TD on top and I get a empty space.
Demo.
My Table Style
<table width="100%">
<tbody>
<tr>
<td style="" width="25%">
<table cellspacing="0">
<tbody>
<tr>
<td>
<img src="/avatar/thumb/1479077526.png" style="width:200px; height:200px;">
</td>
</tr>
<tr>
<td><strong>und3rc00d3</strong>
</td>
</tr>
<tr>
<td>UserID: <strong>1</strong>
</td>
</tr>
</tbody>
</table>
</td>
<td>
<br>
<div id="akt">
<div style="overflow-y:scroll; height:640px;">
<table>
<tbody>
<tr>
<th>Aktivitetet e fundit</th>
</tr>
<tr>
<td>............
</td>
</tr>
</tbody>
</table>
</div>
</div>
</td>
</tr>
</table>
For the first TD I tried to style with: position: absolute; but again it did not work http://prntscr.com/ddom11
Try adding style="vertical-align: top"; as in the code below
<table width="100%">
<tbody>
<tr>
<td style="vertical-align:top" width="25%">
<table cellspacing="0">
<tbody>
<tr>
<td><img src="/avatar/thumb/1479077526.png" style="width:200px; height:200px;"></td>
</tr>
<tr>
<td><strong>und3rc00d3</strong></td>
</tr>
<tr>
<td>UserID: <strong>1</strong></td>
</tr>
</tbody>
</table>
</td>
<td>
<br>
<div id="akt">
<div style="overflow-y:scroll; height:640px;">
<table>
<tbody>
<tr>
<th>Aktivitetet e fundit</th>
</tr>
<tr>
<td>............</td>
</tr>
</tbody>
</table>
</div>
</div>
</td>
</tr>
</tbody>
</table>
What I would like to do:
What did I wrote:
<table>
<TR>
<TD ROWSPAN="4">left</TD>
<TD ROWSPAN="12">middle</TD>
<TD ROWSPAN="3">right</TD>
</TR>
<TR>
<TD ROWSPAN="4">left2</TD>
<TD ROWSPAN="3">right2</TD>
</TR>
<TR>
<TD ROWSPAN="4">left3</TD>
<TD ROWSPAN="3">right3</TD>
</TR>
<TR>
<TD ROWSPAN="3">right4</TD>
</TR>
</table>
It turns out with this:
I would like the table have same height, I can work in this way, but it is not the same height:
<table>
<TR>
<TD>left</TD>
<TD ROWSPAN="12">middle</TD>
<TD>right</TD>
</TR>
<TR>
<TD>left2</TD>
<TD>right2</TD>
</TR>
<TR>
<TD>left3</TD>
<TD>right3</TD>
</TR>
<TR>
<TD>right4</TD>
</TR>
</table>
and the result like this:
Got it! The trick was having a total of twelve <tr>s, even though some of them are empty.
As a point of curiosity, I solved this by making the table in excel, saving as html, and deleting all of the inline styles that excel puts in there.
td {
border: 1px solid black;
}
<table>
<tr>
<td rowspan=4>left</td>
<td rowspan=12>middle</td>
<td rowspan=3>right</td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td rowspan=3>right2</td>
</tr>
<tr>
<td rowspan=4>left2</td>
</tr>
<tr>
</tr>
<tr>
<td rowspan=3>right3</td>
</tr>
<tr>
</tr>
<tr>
<td rowspan=4>left3</td>
</tr>
<tr>
<td rowspan=3>right4</td>
</tr>
<tr>
</tr>
<tr>
</tr>
</table>
I'm editing a web page and i need to create two tables similar to the screenshot attached. Relatively new to html. My code is below. JFiddle for reference as to how it looks currently. https://jsfiddle.net/u97rggyy/
Thanks in advance.
<div id="tabs-container">
<h2>
<table style="width: 100%; text-align:center">
<tbody>
<tr>
<th>
<span>First header links</span></th>
<th>
<span>Other Links</span></th>
</tr>
</tbody>
</table>
</h2>
<div class="link-item">
<table style="width: 50%;">
<tbody style="font-family: segoe ui;">
<tr>
<td>
Link 1 </td>
<td>
<a href="" >Link 2</a> </td>
</tr>
<tr>
<td>
Link 3</td>
<td>
Link 4 </td>
</tr>
</tbody>
</table>
</div>
<table style="display:inline">
<tbody>
<tr>
<td>
Other Link 1
</td>
<td>
Other link 2
</td>
</tr>
</tbody>
</table>
Two tables with separate headings
Would you consider doing it all in one table like this: https://jsfiddle.net/u97rggyy/3/
<table style="width:100%">
<tr>
<th colspan="2"><h2>First header links</h2></th>
<th colspan="2"><h2>Other Links</h2></th>
</tr>
<tr>
<td style="text-align: left;">Link 1</td>
<td style="text-align: right; padding-right: 20px">Link 2</td>
<td style="text-align: left;">Other Link 1</td>
<td style="text-align: right; padding-right: 20px">Other Link 2</td>
</tr>
<tr>
<td style="text-align: left; ">Link 3</td>
<td style="text-align: right; padding-right: 20px">Link 4</td>
<td style="text-align: left;">Other Link 3</td>
<td style="text-align: right; padding-right: 20px">Other Link 4</td>
</tr>
<tr>
<td style="text-align: left;">Link 5</td>
<td style="text-align: right; padding-right: 20px">Link 6</td>
</tr>
</table>
you mean like this?
jsFiddle
<div id="tabs-container">
<table style="text-align:center;display:inline-block;width:30%;">
<tbody>
<tr>
<th colspan="2">HEADER 1</th>
</tr>
<tr>
<td>
Link 1
</td>
<td>
Link 2
</td>
</tr>
<tr>
<td>
Link 3
</td>
<td>
Link 4
</td>
</tr>
<tr>
<td>
Link 5
</td>
<td>
Link 6
</td>
</tr>
<tr>
<td>
Link 7
</td>
<td>
Link 8
</td>
</tr>
</tbody>
</table>
<table style="text-align:center;display:inline-block;width:30%;">
<tbody>
<tr>
<th colspan="2">HEADER 2</th>
</tr>
<tr>
<td>
Other Link 1
</td>
<td>
Other Link 2
</td>
</tr>
<tr>
<td>
Other Link 3
</td>
<td>
Other Link 4
</td>
</tr>
</tbody>
</table>
</div>
One way of doing it is:
<div id="tabs-container">
<h2>
<table style="width: 100%; text-align:center; border:1px solid black;">
<tbody>
<tr>
<th>
<span>First header links</span></th>
<th>
<span>Other Links</span></th>
</tr>
</tbody>
</table>
</h2>
<div class="link-item" style="float:left;">
<table style="width: 50%;">
<tbody style="font-family: segoe ui;">
<tr>
<td>
Link 1 </td>
<td>
Link 2 </td>
</tr>
<tr>
<td>
Link 3</td>
<td>
Link 4 </td>
</tr>
</tbody>
</table>
</div>
<div style="float:right;">
<table style="display:inline;border:1px solid black;">
<tbody>
<tr>
<td>
Other Link 1
</td>
<td>
Other link 2
</td>
</tr>
</tbody>
</table>
</div>
</div>
2nd way: Define one parent table and put these tables in cells of the parent table
<table style="width:100%;border:1px solid black;">
<tr><td colspan="2">
<table style="width:100%;border:1px solid black;">
<tr>
<td>First Header Links</td><td>Other Links</td>
</tr>
</table>
</td>
</tr>
<tr >
<td >
<table style="width:100%;border:1px solid black;">
<tr><td>1</td>
<td>2</td></tr>
</table>
</td>
<td >
<table table style="width:100%;border:1px solid black;">
<tr><td>3</td></tr>
<tr><td>4</td></tr>
</table>
</td>
</tr>
</table>
</table>