我需要一行应该是圆角和row-row之间的间距。所以,我尝试了表格曲线类,如下所示。 任何建议/修改都会有所帮助。
我的CSS -
.table-curved {
border-collapse: separate;
}
.table-curved {
border: solid #ccc 1px;
border-radius: 6px;
border-left:0px;
}
.table-curved tr {
border-left: 1px solid #ccc;
border-top: 1px solid #ccc;
border-radius: 26px;
border-collapse:seperate;
border-spacing:5em;
}
.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;
}
我的HTML -
<table class="table table-curved">
<thead>
<tr>
<th>Schedule Time</th>
<th>First Name</th>
<th>Last Name</th>
<th>Telephone</th>
<th>Status</th>
<th>Contact Score</th>
<th>Last Contacted</th>
<th>Device Type</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
更具体地说,我需要一行看起来像这里的图像
答案 0 :(得分:1)
您可以在border-radius
和td
上尝试th
。请查看以下示例以开始使用。
border-radius
。tr
以获得所需的background-color
方法1:使用伪元素:before
.table-curved {
border-collapse: collapse;
margin-left: 10px;
}
.table-curved th {
padding: 3px 10px;
}
.table-curved td {
position: relative;
background-color: #e5e5e5;
padding: 6px 10px;
border-bottom: 2px solid white;
border-top: 2px solid white;
}
.table-curved td:first-child:before {
content: '';
position: absolute;
border-radius: 8px 0 0 8px;
background-color: coral;
width: 12px;
height: 100%;
left: -12px;
top: 0px;
}
.table-curved td:last-child {
border-radius: 0 5px 5px 0;
}
.table-curved tr:hover td {
background-color: #c5c5c5;
}
.table-curved tr.blue td:first-child:before {
background-color: cornflowerblue;
}
.table-curved tr.green td:first-child:before {
background-color: forestgreen;
}
<table class="table table-curved">
<thead>
<tr>
<th>Schedule Time</th>
<th>First Name</th>
<th>Last Name</th>
<th>Telephone</th>
<th>Status</th>
<th>Contact Score</th>
<th>Last Contacted</th>
<th>Device Type</th>
</tr>
</thead>
<tbody>
<tr class="green">
<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>
</tr>
<tr class="blue">
<td>.</td>
<td>.</td>
<td>.</td>
<td>.</td>
<td>.</td>
<td>.</td>
<td>.</td>
<td>.</td>
</tr>
</tbody>
</table>
方法2:在每行中添加额外/空单元格的解决方案。
.table-curved {
border-collapse: collapse;
}
.table-curved th {
padding: 3px 10px;
}
.table-curved th:first-child {
padding: 6px;
}
.table-curved td {
background-color: #e5e5e5;
padding: 6px 10px;
border-bottom: 2px solid white;
border-top: 2px solid white;
}
.table-curved td:first-child {
padding: 6px;
border-radius: 8px 0 0 8px;
background-color: coral;
}
.table-curved td:last-child {
border-radius: 0 5px 5px 0;
}
.table-curved tr:hover td:not(:first-child) {
background-color: #c5c5c5;
}
.table-curved tr.blue td:first-child {
background-color: cornflowerblue;
}
.table-curved tr.green td:first-child {
background-color: forestgreen;
}
<table class="table table-curved">
<tr>
<th></th>
<th>S.No</th>
<th>Title</th>
<th>Cost</th>
</tr>
<tr class="blue">
<td></td>
<td>1</td>
<td>Title one</td>
<td>$18.0</td>
</tr>
<tr>
<td></td>
<td>2</td>
<td>Title two</td>
<td>$23.4</td>
</tr>
<tr class="green">
<td></td>
<td>3</td>
<td>Title three</td>
<td>$40.5</td>
</tr>
</table>
答案 1 :(得分:1)
你可以使用:在第一栏之前:
我在这里为你创建了一个example:
.table-curved {
border-collapse: separate;
width:100%;
border-spacing:0px;
}
.table-curved {
border: solid #ccc 1px;
border-radius: 6px;
border-left:0px;
}
.table-curved tr {
position: relative;
border-radius: 26px;
border-collapse:seperate;
border-spacing:0;
background:#f8f8f8;
backgrnoud-position-x: 10px;
padding:10px 0;
transition:background .1s;
}
.table-curved tr:hover {
background:#eee;
}
.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;
}
.table-curved td:first-child:before {
content: "";
display: block;
width: 10px;
height: 100%;
left: 0;
top: 0;
border-radius: 6px 0 0 6px;
position: absolute;
}
.table-curved td.red:before {
background:red;
}
.table-curved td.green:before {
background:green;
}
.table-curved td.blue:before {
background:blue;
}
.table-curved td.orange:before {
background:orange;
}
.table-curved td:first-child{
padding-left: 15px;
}
.table-curved td{
position: relative;
border-bottom: 10px solid white;
border-spacing: 0px;
padding: 10px;
}
答案 2 :(得分:0)
您不能将边框半径应用于表格行,而是可以将边界半径添加到TD,这是示例
'http://jsfiddle.net/theazureshadow/LRKXD/1/'