Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I apply a border radius to Bootstrap 3's tables?

I want the top corners and bottom corners of a table to have rounded corners.

How can I do this? Right now, the Bootstrap 3 tables have 0 radius.

like image 515
TIMEX Avatar asked Jan 04 '14 06:01

TIMEX


People also ask

How do you make a rounded table in bootstrap?

Here is a simple way to implement a table with rounded corners using Bootstrap 4. Note the wrapper "card" class, this is what gives the table the rounded corners. This new class replaces the "panel panel-default" classes that previously allowed for rounded corners in Bootstrap 3.

How do you add a border radius to a table tr?

To add border radius to a table row tr , you have to specifically target the first table data td on the row and the last. This Pen is owned by Temitope Ayodele on CodePen.

How do you set a border top radius?

CSS Syntax border-top-left-radius: length|% [length|%]|initial|inherit; Note: If you set two values, the first one is for the top border, and the second one for the left border. If the second value is omitted, it is copied from the first. If either length is zero, the corner is square, not rounded.


2 Answers

Try this :-

<table class="table table-curved">
    ....
</table>    

.table-curved {
    border-collapse: separate;
}
.table-curved {
    border: solid #ccc 1px;
    border-radius: 6px;
    border-left:0px;
}
.table-curved td, .table-curved th {
    border-left: 1px solid #ccc;
    border-top: 1px solid #ccc;
}
.table-curved th {
    border-top: none;
}
.table-curved th:first-child {
    border-radius: 6px 0 0 0;
}
.table-curved th:last-child {
    border-radius: 0 6px 0 0;
}
.table-curved th:only-child{
    border-radius: 6px 6px 0 0;
}
.table-curved tr:last-child td:first-child {
    border-radius: 0 0 0 6px;
}
.table-curved tr:last-child td:last-child {
    border-radius: 0 0 6px 0;
}
like image 139
Anup Avatar answered Sep 22 '22 18:09

Anup


The easiest way is wrap the table with a panel. Then your table will have rounded corners automatically.

Example:

<div class="panel panel-default">
   <table class="table table-striped">
      ....
   </table>
</div>

Note: panel-default will add a 1px grey border. if you want to hide it just add border-color:white; to style of panel-default.

like image 37
Iman Sedighi Avatar answered Sep 23 '22 18:09

Iman Sedighi