How can I change the radius of thead and tr element? I want my table to have rounded corners but border-radius is not working for thead and tr but its works for the element itself. Here is the CSS.
table{
width:100%;
border-radius:5px;
background:gray;
}
thead {
border-radius:5px;
text-align:left;
background:blue;
}
tr{
border-radius:5px;
}
th,td{
padding:5px;
}
Here is the HTML.
<table>
<thead>
<tr>
<th>No</th>
<th>Name</th>
<th>Country</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Andy</td>
<td>UK</td>
<td>40</td>
</tr>
</tbody>
<tbody>
</table>
This is fairly easy to do. You need to add the border radius to the correct corners of the first and last th in the row rather than the thead like this:
th:nth-child(1) {
border-radius: 5px 0px 0px 0px;
}
th:nth-last-child(1) {
border-radius: 0px 5px 0px 0px;
}
Here is a full code snippet:
table{
width:100%;
border-radius:5px;
background:gray;
}
tr{
border-radius:5px;
}
th,td{
padding:5px;
}
th{
text-align:left;
background:blue;
color: #fff;
}
th:nth-child(1) {
border-radius: 5px 0px 0px 0px;
}
th:nth-last-child(1) {
border-radius: 0px 5px 0px 0px;
}
<table>
<thead>
<tr>
<th>No</th>
<th>Name</th>
<th>Country</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Andy</td>
<td>UK</td>
<td>40</td>
</tr>
</tbody>
<tbody>
</table>
radius needs to be in a th or td so i'd do something like this:
table{
width:100%;
border-radius:5px;
background:gray;
border-collapse: separate;
}
table th {
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
text-align:left;
background:blue;
}
table td{
border-radius:5px;
}
th,td{
padding:5px;
}
td {
border: solid 1px #000;
border-style: solid none;
padding: 10px;
background-color: cyan;
}
td:first-child {
border-left-style: solid;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
}
td:last-child {
border-right-style: solid;
border-bottom-right-radius: 10px;
border-top-right-radius: 10px;
}
<table>
<thead>
<tr>
<th>No</th>
<th>Name</th>
<th>Country</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Andy</td>
<td>UK</td>
<td>40</td>
</tr>
</tbody>
<tbody>
</table>
You need to add "th" in the css. Then you have to use "border-radius".
thead th{
border-radius: 10px 10px 10px 10px;
text-align:left;
background:blue;
}
Add "border-radius" in td too.
td{
border-radius: 10px 10px 10px ;
background-color: red;
}
Related
Is it possible to have the side borders of HTML tables like this:
A vertical line that is not connected to the top and bottom of the table.
You can try this :
body{
background:grey;
}
table, th, td {
border-top: 1px solid #fff;
border-bottom : 1px solid #fff;
border-collapse: collapse;
text-align:center;
padding:10px;
}
table
{
position: absolute ;
left:50%;
top:50%;
transform:translate(-50%,-50%);
border:2px solid #fff;
}
td
{
position:relative ;
}
td::after
{
content:'';
position:absolute ;
height:70%;
width:100%;
left:0;
top:7px;
border-left:3px solid #fff;
}
td:nth-child(1)::after
{
display:none;
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<table style="width:20%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
</body>
</html>
.table {
background-color: #272727;
width: 100%;
text-align: left;
border-collapse: collapse;
}
.table__body-row {
height: 41px;
border-bottom: 1px solid #000000;
}
.table__body-row.filled {
background: #191919;
}
.table__body-cell {
font-size: 14px;
color: #FFFFFF;
border: none;
}
.table__header {
background: #000000;
}
.table__header-row {
height: 40px;
}
.table__header-cell {
font-size: 12px;
font-weight: 400;
color: #FFFFFF;
text-align: left;
padding: 0 16px 0 16px;
}
.table__cell-body {
border-right: 1px solid #000000;
padding: 0 10px 0 10px;
min-height: 17px;
}
.table__body-cell:last-of-type .table__cell-body {
border-right: none;
}
<table class="table">
<thead class="table__header">
<tr class="table__header-row">
<th class="table__header-cell">
Header 1
</th>
<th class="table__header-cell">
Header 2
</th>
</tr>
</thead>
<tbody id="tableBody">
<tr class="table__body-row">
<td class="table__body-cell">
<div class="table__cell-body"></div>
</td>
<td class="table__body-cell">
<div class="table__cell-body"></div>
</td>
</tr>
</tbody>
</table>
This can be done using a nested div with a border. Please see snippet.
I made a HTML table with columns headers as tabs. I want to apply border-radius to my table rows on both sides. But I don't know exactly how to apply. Though I tried but it didn't work at all. I have white color space between each row as well using white border. I have also applied blue left border to my each row. I want to curve its top and bottom corners. And also want to apply round corners to the right side of rows.
Actually this is what I am trying to achieve:
Left side
Right side
Also when you zoom in webpage, the blue border on left hand is touched to each other. Why? In normal view, its fine.
#tbstud {
width:700px;
margin:50px auto;
border-collapse:collapse;
}
.column_heading {
background-color:#d9e5f0;
border-left:1px solid #ffffff;
border-radius:5px 5px 0 0;
color:#000;
font-weight:bold;
height:20px;
line-height:20px;
padding:10px;
text-align:center;
}
.customer_row td {
padding:15px;
border-left:1px solid #ffffff;
}
.customer_row {
background-color:#f5f7f9;
border-bottom:1px solid #e5e9ee;
border-left:3px solid #2585fe;
border-top:2px solid #fff;
color:#545454;
border-radius:5px;
}
#tbstud .customer_row:nth-child(2) {
border-top:none;
}
#tbstud .customer_row:last-child {
border-bottom:none;
}
<table id="tbstud">
<tr>
<th>Sr. No.</th>
<th class="column_heading">Roll No.</th>
<th class="column_heading">Name</th>
<th class="column_heading">Class</th>
<th class="column_heading">Address</th>
</tr>
<tr class="customer_row">
<td>1</td>
<td>101</td>
<td>Sam</td>
<td>MSc</td>
<td>Delhi</td>
</tr>
<tr class="customer_row">
<td>2</td>
<td>102</td>
<td>Amit</td>
<td>BCA</td>
<td>Mumbai</td>
</tr>
<tr class="customer_row">
<td>3</td>
<td>103</td>
<td>Rahul</td>
<td>BCA</td>
<td>Delhi</td>
</tr>
<tr class="customer_row">
<td>4</td>
<td>104</td>
<td>Neha</td>
<td>BA</td>
<td>Pune</td>
</tr>
<tr class="customer_row">
<td>5</td>
<td>105</td>
<td>Pooja</td>
<td>B.Tech.</td>
<td>Chandigarh</td>
</tr>
</table>
You can try this code..
#tbstud {
width:700px;
margin:50px auto;
border-collapse:collapse;
}
.column_heading { background-color:#d9e5f0;
border-left:1px solid #ffffff;
border-radius:5px 5px 0 0;
color:#000;
font-weight:bold;
height:20px;
line-height:20px;
padding:10px;
text-align:center;
}
.customer_row td {border-left:1px solid #ffffff;}
.customer_row td span{
display: block;
padding:15px;
background-color: #f5f7f9;
}
.customer_row {
border-bottom:1px solid #e5e9ee;
border-top:2px solid #fff;
color:#545454;
border-radius:5px;
}
.customer_row td:first-child span{ border-left:3px solid #2585fe;border-radius: 4px; }
.customer_row td:last-child span{border-radius: 4px;}
#tbstud .customer_row:nth-child(2) {
border-top:none;
}
#tbstud .customer_row:last-child {
border-bottom:none;
}
<table id="tbstud">
<tr>
<th>Sr. No.</th>
<th class="column_heading">Roll No.</th>
<th class="column_heading">Name</th>
<th class="column_heading">Class</th>
<th class="column_heading">Address</th>
</tr>
<tr class="customer_row">
<td><span>1</span></td>
<td><span>101</span></td>
<td><span>Sam</span></td>
<td><span>MSc</span></td>
<td><span>Delhi</span></td>
</tr>
<tr class="customer_row">
<td><span>2</span></td>
<td><span>102</span></td>
<td><span>Amit</span></td>
<td><span>BCA</span></td>
<td><span>Mumbai</span></td>
</tr>
<tr class="customer_row">
<td><span>3</span></td>
<td><span>103</span></td>
<td><span>Rahul</span></td>
<td><span>BCA</span></td>
<td><span>Delhi</span></td>
</tr>
<tr class="customer_row">
<td><span>4</span></td>
<td><span>104</span></td>
<td><span>Neha</span></td>
<td><span>BA</span></td>
<td><span>Pune</span></td>
</tr>
<tr class="customer_row">
<td><span>5</span></td>
<td><span>105</span></td>
<td><span>Pooja</span></td>
<td><span>B.Tech.</span></td>
<td><span>Chandigarh</span></td>
</tr>
</table>
.bordered {
border: 1px solid #CCCCCC;
border-radius: 6px 6px 6px 6px;
-moz-border-radius: 6px 6px 6px 6px;
-webkit-border-radius: 6px 6px 6px 6px;
box-shadow: 0 1px 1px #CCCCCC;
}
table {
border-spacing: 0;
width: 600px;
margin: 30px;
}
.bordered th:first-child {
border-radius: 6px 0 0 0;
-moz-border-radius: 6px 0 0 0;
-webkit-border-radius: 6px 0 0 0;
}
.bordered th:last-child {
border-radius: 0 6px 0 0;
-moz-border-radius: 0 6px 0 0;
-webkit-border-radius: 0 6px 0 0;
}
.bordered td:first-child, .bordered th:first-child {
border-left: medium none;
}
.bordered th {
background-color: #DCE9F9;
background-image: -moz-linear-gradient(center top , #F8F8F8, #ECECEC);
background-image: -webkit-gradient(linear, 0 0, 0 bottom, from(#F8F8F8), to(#ECECEC), color-stop(.4, #F8F8F8));
border-top: medium none;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}
.bordered td, .bordered th {
border-left: 1px solid #CCCCCC;
border-top: 1px solid #CCCCCC;
padding: 10px;
text-align: left;
}
<table class="bordered">
<thead>
<tr>
<th><label>Labels</label></th>
<th><label>Labels</label></th>
<th><label>Labels</label></th>
<th><label>Labels</label></th>
<th><label>Labels</label></th>
</tr>
</thead>
<tbody>
<tr>
<td><label>Value</label></td>
<td><label>Value</label></td>
<td><label>Value</label></td>
<td><label>Value</label></td>
<td><label>Value</label></td>
</tr>
</tbody>
</table>
Please refer this:
Border Radius of Table is not working
.customer_row td:first-child {
border-left:3px solid #2585fe;
border-radius:5px;
display: block;
}
Just use border-collapse: separate; on the table and set the border radius and blue left border on the first td of every tr (tr td:first-child {}).
I styled a HTML table like this
I want to remove space between table column headers and their below row. I tried various tricks but nothing worked. Please note that I am also using Eric Meyer's Reset CSS v2.0.
I want to remove this red marked space without disturbing others.
My code:
#tbstud {
width:700px;
margin:50px auto;
border-collapse:separate;
border-spacing:2px;
}
.column_heading {
background-color:#d9e5f0;
-moz-border-radius:5px 5px 0 0;
-webkit-border-radius:5px 5px 0 0;
border-radius:5px 5px 0 0;
color:#000;
font-weight:bold;
height:20px;
line-height:20px;
padding:10px;
text-align:center;
}
.customer_row td {
padding:15px;
background-color:#f5f7f9;
}
.customer_row td:first-child {
border-left:3px solid #2585fe;
border-radius:5px 0 0 5px
}
.customer_row td:last-child {
border-radius:0 5px 5px 0
}
#tbstud .customer_row:nth-child(2) td:last-child {
border-radius:0 0 5px 0
}
<link rel="stylesheet" type="text/css" href="https://meyerweb.com/eric/tools/css/reset/reset.css" />
<table id="tbstud">
<tr>
<th>Sr. No.</th>
<th class="column_heading">Roll No.</th>
<th class="column_heading">Name</th>
<th class="column_heading">Class</th>
<th class="column_heading">Address</th>
</tr>
<tr class="customer_row">
<td>1</td>
<td>101</td>
<td>Sam</td>
<td>MSc</td>
<td>Delhi</td>
</tr>
<tr class="customer_row">
<td>2</td>
<td>102</td>
<td>Amit</td>
<td>BCA</td>
<td>Mumbai</td>
</tr>
<tr class="customer_row">
<td>3</td>
<td>103</td>
<td>Rahul</td>
<td>BCA</td>
<td>Delhi</td>
</tr>
<tr class="customer_row">
<td>4</td>
<td>104</td>
<td>Neha</td>
<td>BA</td>
<td>Pune</td>
</tr>
<tr class="customer_row">
<td>5</td>
<td>105</td>
<td>Pooja</td>
<td>B.Tech.</td>
<td>Chandigarh</td>
</tr>
</table>
I still need gap between each row and each cell. But just need to remove this gap between very first row and below its row.
Please remove border-spacing and use table border property. You cannot restrict border-spacing for tbody only instead what we can do is remove the border-spacing property and use border property for the table tr td
#tbstud {
width:700px;
margin:50px auto;
border-collapse:separate;
/* border-spacing:2px; */
}
/* Check Here*/
table tr td {
border: 3px solid white;
border-top: 0;
}
table tr th {
border: 2px solid white;
border-top: 0;
border-bottom: 0;
}
.column_heading {
background-color:#d9e5f0;
-moz-border-radius:5px 5px 0 0;
-webkit-border-radius:5px 5px 0 0;
border-radius:5px 5px 0 0;
color:#000;
font-weight:bold;
height:20px;
line-height:20px;
padding:10px;
text-align:center;
}
.customer_row td {
padding:15px;
background-color:#f5f7f9;
}
.customer_row td:first-child {
border-left:3px solid #2585fe;
border-radius:5px 0 0 5px
}
.customer_row td:last-child {
border-radius:0 5px 5px 0
}
#tbstud .customer_row:nth-child(2) td:last-child {
border-radius:0 0 5px 0
}
<link rel="stylesheet" type="text/css" href="https://meyerweb.com/eric/tools/css/reset/reset.css" />
<table id="tbstud">
<tr>
<th>Sr. No.</th>
<th class="column_heading">Roll No.</th>
<th class="column_heading">Name</th>
<th class="column_heading">Class</th>
<th class="column_heading">Address</th>
</tr>
<tr class="customer_row">
<td>1</td>
<td>101</td>
<td>Sam</td>
<td>MSc</td>
<td>Delhi</td>
</tr>
<tr class="customer_row">
<td>2</td>
<td>102</td>
<td>Amit</td>
<td>BCA</td>
<td>Mumbai</td>
</tr>
<tr class="customer_row">
<td>3</td>
<td>103</td>
<td>Rahul</td>
<td>BCA</td>
<td>Delhi</td>
</tr>
<tr class="customer_row">
<td>4</td>
<td>104</td>
<td>Neha</td>
<td>BA</td>
<td>Pune</td>
</tr>
<tr class="customer_row">
<td>5</td>
<td>105</td>
<td>Pooja</td>
<td>B.Tech.</td>
<td>Chandigarh</td>
</tr>
</table>
Maybe you can use this kind of hack:
<link rel="stylesheet" type="text/css" href="https://meyerweb.com/eric/tools/css/reset/reset.css" />
<table id="tbstud">
<thead>
<tr>
<th>Sr. No.</th>
<th>
<div class="column_heading">Roll No.</div>
</th>
<th>
<div class="column_heading">Name</div>
</th>
<th>
<div class="column_heading">Class</div>
</th>
<th>
<div class="column_heading">Address</div>
</th>
</tr>
</thead>
<tbody>
<tr class="customer_row">
<td>1</td>
<td>101</td>
<td>Sam</td>
<td>MSc</td>
<td>Delhi</td>
</tr>
<tr class="customer_row">
<td>2</td>
<td>102</td>
<td>Amit</td>
<td>BCA</td>
<td>Mumbai</td>
</tr>
<tr class="customer_row">
<td>3</td>
<td>103</td>
<td>Rahul</td>
<td>BCA</td>
<td>Delhi</td>
</tr>
<tr class="customer_row">
<td>4</td>
<td>104</td>
<td>Neha</td>
<td>BA</td>
<td>Pune</td>
</tr>
<tr class="customer_row">
<td>5</td>
<td>105</td>
<td>Pooja</td>
<td>B.Tech.</td>
<td>Chandigarh</td>
</tr>
</tbody>
</table>
#tbstud {
width: 700px;
margin: 50px auto;
border-collapse: separate;
border-spacing: 2px;
}
.column_heading {
background-color: #d9e5f0;
-moz-border-radius: 5px 5px 0 0;
-webkit-border-radius: 5px 5px 0 0;
border-radius: 5px 5px 0 0;
color: #000;
font-weight: bold;
height: 20px;
line-height: 20px;
padding: 10px;
text-align: center;
margin-bottom: -2px;
}
.customer_row td {
padding: 15px;
background-color: #f5f7f9;
}
.customer_row td:first-child {
border-left: 3px solid #2585fe;
border-radius: 5px 0 0 5px;
}
.customer_row td:last-child {
border-radius: 0 5px 5px 0;
}
#tbstud .customer_row:nth-child(2) td:last-child {
border-radius: 0 0 5px 0;
}
Working codepen: https://codepen.io/leo-melin/pen/rNaWxOq
So you just put the contents of tags inside divs that have margin-bottom: -2px css in addition to normal heading style.
Also added <thead> and <tbody> tags
removed border-spacing
no gap only after header
black color as example to be visible
#tbstud tr th{
border: 1px solid black;
border-bottom: 0px;
}
.customer_row td{
border: 1px solid black;
}
#tbstud tr:last-child td{
border-bottom: 2px solid black;
}
.customer_row:nth-child(2) td{
border-top: 0px;
}
If I understood what you mean then the solution would be to give the .column_heading a position: relative;, then add a .column_heading:after to add a line and the bottom of the <th> tag.
Try this
.column_heading:after {
content: '';
position: absolute;
left: 0;
bottom: -3px;
width: 100%;
height: 3px;
background-color: #d9e5f0;
}
Don't forget to give the .column_heading a position: relative;
Hope this help =]
Remove border-spacing property on #tbstud
and add this css
.column_heading{
border-left: 1px solid #fff;
}
.customer_row td {
border-left: 1px solid #fff;
border-bottom: 1px solid #fff;
}
I want add space between row on table like image below:
If possible please show your code to me.
The border-spacing property will work for this particular case.
table {
border-collapse:separate;
border-spacing: 0 1em;
}
https://developer.mozilla.org/en-US/docs/Web/CSS/border-spacing
Or you can use the hacky approach. That give the appearance of margins between table rows i
tr{
border: 5px solid white;
}
You can use border-spacing. Here is an simple example.
table, th, td {
background: #ffffff;
padding: 5px;
}
table {
background: #999999;
border-spacing: 15px;
}
<h2>Border Spacing</h2>
<p>Border spacing specifies the space between the cells.</p>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
<p>Try to change the border-spacing to 5px.</p>
https://www.w3schools.com/html/html_tables.asp
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_cellspacing
The border-spacing property sets the distance between the borders of adjacent cells.
Note: This property works only when border-collapse is separate.
table {
border-collapse: separate;
border-spacing: 15px;
}
You cannot give margin to the table row. you can either give border-colapse and border spacing to the table or give border to table row and change its color to table background color. Plz refer below link.
Thanks
http://jsfiddle.net/x1hphsvb/10966/
table{
border-collapse: separate;
border-spacing: 0 20px;
background-color: #e3e7ee
}
table tr td{
padding:20px !important;
background-color:white;
}
/* this is the second option */
tr{
/* border:2px solid #e3e7ee !important */
}
<table class="table ">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
<td>john#example.com</td>
</tr>
<tr>
<td>Mary</td>
<td>Moe</td>
<td>mary#example.com</td>
</tr>
<tr>
<td>July</td>
<td>Dooley</td>
<td>july#example.com</td>
</tr>
</tbody>
</table>
Try to use this for the design
or visit for more code demo
#import "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css";
.caseTableWrap {
margin-bottom: 50px;
background: #f5f5f5;
padding: 20px; }
.caseTable {
border-collapse: separate;
border-spacing: 0 20px; }
.caseTable tr {
-webkit-box-shadow: 0px 10px 10px rgba(0, 0, 0, 0.05);
box-shadow: 0px 10px 10px rgba(0, 0, 0, 0.05);
-webkit-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s; }
.caseTable tr + tr {
cursor: pointer; }
.caseTable tr + tr:hover {
-webkit-transform: translateY(-2px);
-ms-transform: translateY(-2px);
transform: translateY(-2px);
-webkit-box-shadow: 0px 10px 10px rgba(0, 0, 0, 0.2);
box-shadow: 0px 10px 10px rgba(0, 0, 0, 0.2); }
.caseTable tr .caseTableData:last-child, .caseTable tr th:last-child, .caseTable tr td:last-child {
max-width: 220px; }
.caseTable tr th {
border: none;
font-size: 18px;
font-weight: 500; }
.caseTable tr th:first-child {
border-radius: 8px 0 0 8px; }
.caseTable tr th:last-child {
border-radius: 0 8px 8px 0; }
.caseTable tr td {
border: none;
position: relative; }
.caseTable tr td:first-child {
border-radius: 8px 0 0 8px; }
.caseTable tr td:last-child {
border-radius: 0 8px 8px 0; }
.caseTable tr .caseTableData, .caseTable tr th, .caseTable tr td {
background: #fff;
padding: 20px;
position: relative; }
.caseTable tr .caseTableData p, .caseTable tr th p, .caseTable tr td p {
color: #484848;
font-size: 16px;
font-weight: 400; }
<div class="caseTableWrap">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="caseTableInner">
<h3 class="secTitle">
<div class="text">
Recent Case
</div>
</h3>
<div class="caseTableWrap table-responsive">
<table class="table caseTable">
<tr>
<th>Case ID</th>
<th>Created Date</th>
<th>Expiry Date</th>
<th>Status</th>
</tr>
<tr>
<td>75814</td>
<td>01 January 2020</td>
<td>30 January 2020</td>
<td>Delivered</td>
</tr>
<tr>
<td>75814</td>
<td>01 January 2020</td>
<td>30 January 2020</td>
<td>Delivered</td>
</tr>
<tr>
<td>75814</td>
<td>01 January 2020</td>
<td>30 January 2020</td>
<td>Delivered</td>
</tr>
<tr>
<td>75814</td>
<td>01 January 2020</td>
<td>30 January 2020</td>
<td>Delivered</td>
</tr>
<tr>
<td>75814</td>
<td>01 January 2020</td>
<td>30 January 2020</td>
<td>Delivered</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
Best option:
*{box-sizing: border-box}
table {
border-collapse: separate;
}
tr > td {
display: inline-block;
margin-top: 1rem;
border-right: 1px solid black;
border-bottom: 1px solid black;
border-top: 1px solid black;
}
tr > td:first-of-type {
border-left: 1px solid black;
}
you can add top and bottom borders with the same color as the background
table{
width: 100%;
border-collapse: collapse;
}
tr{border-bottom: 4px solid white;border-radius: 10px;}
th{ background-color: white;}
td{ background-color: grey;}
<table>
<thead>
<tr>
<th>Name</th>
<th>id</th>
</tr>
</thead>
<tbody>
<tr>
<td>BDR</td>
<td>1</td>
</tr>
<tr>
<td>Bader</td>
<td>2</td>
</tr>
</tbody>
</table>
I'm trying to create a table with 4 columns and at least 12 rows with an overflow-y:scroll. The page is fully responsive. I understand that if I need to add a scrollbar to the table I need to make it display: block on thead as well as tbody. Now the problem that I'm facing is I can't have my trows to have 100% of the width. I've tried to tweak my code for hours now and cannot seem to reach any solution. Attaching the jsfiddle link below
https://jsfiddle.net/kuau4ace/
`
I am only trying to use HTML and CSS with this.
Kindly help!
<table>
By making thead and tbody to display:block you have changed the property of table,thats why tr don't take width:100%.
Try this code
$(document).ready(function(){
var body=$('.template_table').clone();
body.addClass('body');
$('.table-wrapper').append("<div class='table-body'></div>");
$('.table-body').append(body);
var curr = [];
$("table.body th").each(function(i) {
var tColumnWidth = $(this).width();
curr.push(tColumnWidth);
});
$("table:first-child th").each(function(i){
$(this).width(curr[i]);
});
$("table.body thead").empty();
$(".table-wrapper>table tbody").empty();
});
.template_table{
border:1px solid #000;
width:100%;
padding: 0;
}
.template_table thead{
background:#323333;
height: 30px;
width: 100%;
}
.template_table tbody{
height: 210px;
width: 100%;
overflow-x: hidden;
overflow-y: auto;
}
.template_table th{
border:1px solid #000;
border-left:0;
border-right:0
}
.template_table th select{
background:none;
border:none;
border-right:1px solid #323232;
color:#fff;
padding:5px;
width:80%;
}
.template_table th{
width:330px;
}
.template_table th:first-child{
width:80px;
border:1px solid #000;
}
.template_table th:nth-child(2){
width:220px;
border:1px solid #000;
}
.template_table td:first-child{
width:80px;
}
.template_table td:nth-child(2){
width:220px;
}
.template_table td{
width:220px;
color: #c3bfbf;
border-bottom:1px solid #000;
}
.template_table tbody tr:hover td{
background:#676767;
color:#fff;
}
.template_table th{
border:1px solid #000;
border-left:0;
border-right:0;
}
.template_table th select{
background:none;
border:none;
border-right:1px solid #323232;
color:#fff;
padding:5px;
width:80%;
}
.template_table th:first-child{
width:80px;
border:1px solid #000;
}
.template_table th:nth-child(2){
width:220px;
border:1px solid #000;
}
.template_table td:first-child{
width:17%;
}
.template_table td:nth-child(2){
width:37%;
}
.template_table td:nth-child(3) {
}
.template_table td{
color:#807c7c;
border-bottom:1px solid #000;
}
.template_table tbody tr:hover td{
background:#676767;
color:#fff;
}
tbody tr{
cursor:pointer;
}
.table-wrapper {
width: calc(100% - 20px);
}
.table-body {
height: 200px;
overflow-x: hidden;
overflow-y: auto;
width: calc(100% + 15px);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<div class="table-wrapper">
<table class="col-xs-12 template_table">
<thead>
<tr>
<th></th>
<th>
<select>
<option>Page Name </option>
</select>
</th>
<th>
<select>
<option>Template</option>
</select>
</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>Video Source 1 </td>
<td>Video Clip</td>
</tr>
<tr>
<td></td>
<td>ManningL3 </td>
<td>Player L3</td>
</tr>
<tr>
<td></td>
<td>Boyriven </td>
<td>Talent ID</td>
</tr>
<tr>
<td></td>
<td>Halftime Stats </td>
<td>Full Screen Stats</td>
</tr>
<tr>
<td></td>
<td>Locator </td>
<td>Full Screen Locator</td>
</tr>
<tr>
<td></td>
<td>Locator </td>
<td>Full Screen Locator</td>
</tr>
<tr>
<td></td>
<td>Locator </td>
<td>Full Screen Locator</td>
</tr>
<tr>
<td></td>
<td>Time </td>
<td>Bug</td>
</tr>
<tr>
<td></td>
<td>Singular Info </td>
<td>Topic L3</td>
</tr>
<tr>
<td></td>
<td>Los Angeles</td>
<td>Locator</td>
</tr>
<tr>
<td></td>
<td>Lewandowski </td>
<td>Player L3</td>
</tr>
<tr>
<td></td>
<td>Lewandowski </td>
<td>Player L3</td>
</tr>
</tbody>
</table>
</div>