Border radius can't be applied to my HTML table - html

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 {}).

Related

How to remove space between column headers and their below row in a HTML table?

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;
}

Unable to change the border radius of <thead>, <tr> elements

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;
}

How to color all 4 sides of a TD cell border via CSS in an HTML table?

I have this code where I am trying to color all 4 sides of a TD cell with red, but if you run the code, only the bottom and the right border are getting color (in Mozilla Firefox). Is there a way to color all 4 borders?
#selections_table table {
border-collapse: collapse;
}
#selections_table td,
th {
border: 1px solid black;
padding: 3px 4px 3px 4px;
}
<div id="selections_table">
<table>
<tbody>
<tr>
<th>#</th>
<th>Model</th>
</tr>
<tr>
<td>1</td>
<td style="border-color:red">XXX-8</td>
</tr>
</tbody>
</table>
</div>
This question/answer does not help: CSS Border declare 4 sides, color, width, in one line
If there is a way to style it via a class, that will be better than using a an inline style command.
Change your inline style to style="border:1px double red;":
<div id="selections_table">
<table>
<tbody>
<tr>
<th>#</th>
<th>Model</th>
</tr>
<tr>
<td>1</td>
<td style="border:1px double red;">XXX-8</td>
</tr>
</tbody>
</table>
</div>
A little trick, create an ::after to the td you want to add the border.
#selections_table table {
border-collapse: collapse;
}
#selections_table td,
th {
border: 1px solid black;
padding: 3px 4px 3px 4px;
position:relative;
}
#selections_table td.border-red::after{
content: "";
position: absolute;
top: -1px;
left: -1px;
right: -1px;
bottom: -1px;
border: 1px solid red;
}
<div id="selections_table">
<table>
<tbody>
<tr>
<th>#</th>
<th>Model</th>
</tr>
<tr>
<td>1</td>
<td class="border-red">XXX-8</td>
</tr>
</tbody>
</table>
</div>
https://jsfiddle.net/ym82a0k7/
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid red;
}
</style>
</head>
<body>
<div id="selections_table">
<table>
<tbody>
<tr>
<th>#</th>
<th>Model</th>
</tr>
<tr>
<td>1</td>
<td>XXX-8</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
First, you don't need to declare td here:
#selections_table td,th {
border: 1px solid black;
padding: 3px 4px 3px 4px;
}
So,
#selections_table th {
border: 1px solid black;
border-bottom: 1px solid red;
padding: 3px 4px 3px 4px;
}
td {
border: 1px solid red;
}
This is another option (by increasing the pixel, it is not a good practice but another option)
#selections_table th {
border: 1px solid black;
padding: 3px 4px 3px 4px;
}
td {
border: 2px solid red;
}
or just like this:
#selections_table th {
border: 1px solid black;
padding: 3px 4px 3px 4px;
}
td {
border: 1px double red;
}

How to add margin on table row

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>

CSS: no top,right and bottom border on a table cells

I am trying to get a table with the last column cells (and header) having nor right, top and bottom border. I have searched Sobut i am unable to make what I found work,
This fiddle shows what I have tried: https://jsfiddle.net/prtome/taqge61v/
HTML
<table class="asktable">
<thead>
<th> col1</th>
<th> col1</th>
<th class="no-border-right"> col no border</th>
</thead>
<tbody><td>a</td><td>b</td><td>cell no border</td></tbody>
</table>
CSS
.asktable {
border-collapse: collapse;
border: 1px solid #ccc;
}
.asktable th {
padding: 4px 8px;
border: 1px solid #ccc;
}
.asktable td {
padding: 4px 8px;
border: 1px solid #ccc;
}
.asktable th.no-border-right{
border-top:0;
border-right:0 !important;
border-bottom:0;
}
Where is my error ? thanks for any pointer
You have a border set on the whole table so even with this removed from the th and td the border will still appear.
Also as a side note, you can do away with the extra classes to remove the border by using :last-child and omit the !important.
Ive edited your CSS below.
.asktable {
border-collapse: collapse;
}
.asktable th {
padding: 4px 8px;
border: 1px solid #ccc;
}
.asktable td {
padding: 4px 8px;
border: 1px solid #ccc;
}
.asktable th:last-child,
.asktable td:last-child {
border-top: 0;
border-right: 0;
border-bottom: 0;
}
<table class="asktable">
<thead>
<th>col1</th>
<th>col1</th>
<th class="no-border-right">col no border</th>
</thead>
<tbody>
<td>a</td>
<td>b</td>
<td>cell no border</td>
</tbody>
</table>
<p>
<br>
</p>
<table class="asktable no-border-right">
<thead>
<th>col1</th>
<th>col1</th>
<th class="no-border-right">col no border</th>
</thead>
<tbody>
<td>a</td>
<td>b</td>
<td>ccell no border</td>
</tbody>
</table>
Use hidden instead of 0, for example:
border-top:hidden !important;
border-right:hidden !important;
border-bottom:hidden !important;
remove border to table
.asktable {
/*border: 1px solid #ccc;*/
border-collapse: collapse;
}
https://jsfiddle.net/taqge61v/8/
You should use border-xxx-color:transparent; where you want no border. It will helps you.
.asktable {
border-collapse: collapse;
border: 1px solid #ccc;
}
.asktable th {
padding: 4px 8px;
border: 1px solid #ccc;
}
.asktable td {
padding: 4px 8px;
border: 1px solid #ccc;
}
/*.asktable th.no-border-right{
border-top-color:transparent !important;
border-right-color:transparent !important;
border-bottom-color:transparent !important;
}*/
.asktable .no-border-right{
border-top-color:transparent !important;
border-right-color:transparent !important;
border-bottom-color:transparent !important;
}
<table class="asktable">
<thead>
<th> col1</th>
<th> col1</th>
<th class="no-border-right"> col no border</th>
</thead>
<tbody>
<td>a</td>
<td>b</td>
<td>cell no border</td>
</tbody>
</table>
<p>
<br>
</p>
<table class="asktable no-border-right">
<thead>
<th> col1</th>
<th> col1</th>
<th class="no-border-right"> col no border</th>
</thead>
<tbody>
<td>a</td>
<td>b</td>
<td>ccell no border</td>
</tbody>
</table>