2016-04-14 43 views
0

我想使用带边框的引导程序3表格,例如使用class="table table-bordered",这样我会在单元格之间有边框,但是我不希望表格外部有任何边框bootstrap3表格边界没有外部边界

我尝试了以下方法,并且它似乎适用于两侧,但考虑到theadtfoot是可选元素,我无法想出一个处理潜在顶部和底部边界的好方法。我希望能够做出强有力的事情来解决这些情况,最大限度地发挥潜力。

.table-bordered.no-outside-borders { 
    border: none; 
} 

.table-bordered.no-outside-borders>thead>tr>td:first-child, 
.table-bordered.no-outside-borders>thead>tr>th:first-child, 
.table-bordered.no-outside-borders>tfoot>tr>td:first-child, 
.table-bordered.no-outside-borders>tfoot>tr>td:first-child, 
.table-bordered.no-outside-borders>tbody>tr>td:first-child, 
.table-bordered.no-outside-borders>tbody>tr>th:first-child { 
    border-left: none; 
} 

.table-bordered.no-outside-borders>thead>tr>td:last-child, 
.table-bordered.no-outside-borders>thead>tr>th:last-child, 
.table-bordered.no-outside-borders>tfoot>tr>td:last-child, 
.table-bordered.no-outside-borders>tfoot>tr>th:last-child, 
.table-bordered.no-outside-borders>tbody>tr>td:last-child, 
.table-bordered.no-outside-borders>tbody>tr>th:last-child { 
    border-right: none; 
} 

在这里有一个很好的CSS解决方案吗?

回答

0

昨天我有同样的问题,我用这个CSS代码为:

.table-borderless tbody tr td, .table-borderless tbody tr th, .table-borderless thead tr th { 
    border: none; 
    max-height: 200px; 
    font-size: 20px; 

    border-right: 1px solid gray; 
    border-collapse: collapse; 
} 
.table.table-borderless { 


    border-right: 1px solid gray; 
    border-collapse: collapse; 
    max-height: 200px; 
    font-size: 20px; 
}