我有点卡住了CSS的问题,而使用Bootstrap。我也使用Angular JS和Angular UI。引导(这可能是问题的一部分)。

我正在做一个以表格形式显示数据的网站。 有时,数据包含我必须在表中显示的对象。 我想把无界表放到普通表中,同时为无界表保留分隔线。

但似乎即使我明确地说不要在表格上显示边界,它也是被迫的:

HTML:

<table class='table borderless'>

CSS:

.borderless table {
    border-top-style: none;
    border-left-style: none;
    border-right-style: none;
    border-bottom-style: none;
}

这里,我想要的只是内部边界。


当前回答

使用Boostrap 4中的border类

<td class="border-0"></td>

or

<table class='table border-0'></table>

请确保在类输入结束时使用您想要执行的最后一个更改。

其他回答

不要将.table类添加到<table>标记中。从Bootstrap文档中的表:

对于基本样式—轻填充和仅水平分隔—将基类.table添加到任何<table>。这看起来可能非常多余,但考虑到其他插件(如日历和日期选择器)广泛使用表格,我们选择隔离我们的自定义表格样式。

这个方法对我很管用。

<td style="border-top: none;">;

关键是你需要添加border-top到<td>

我在这里玩的很晚,但是FWIW:将.table-bordered添加到.table中只是用边框包装了表,尽管是通过为每个单元格添加完整的边框。

但是删除.table边界仍然保留规则行。这是一个语义问题,但为了与BS3+命名法保持一致,我使用了以下一组重写:

.table.table-unruled>tbody>tr>td, .table.table-unruled>tbody>tr>th { border-top: 0 none transparent; border-bottom: 0 none transparent; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> <div class="container"> <div class="row"> <div class="col-xs-5"> .table <table class="table"> <thead> <tr> <th>a</th> <th>b</th> <th>c</th> </tr> </thead> <tbody> <tr> <td>a</td> <td>b</td> <td>c</td> </tr> <tr> <td>a</td> <td>b</td> <td>c</td> </tbody> <tfoot> <tr> <th>a</th> <th>b</th> <th>c</th> </tr> </tfoot> </table> </div> <div class="col-xs-5 col-xs-offset-1"> <table class="table table-bordered"> .table .table-bordered <thead> <tr> <th>a</th> <th>b</th> <th>c</th> </tr> </thead> <tbody> <tr> <td>a</td> <td>b</td> <td>c</td> </tr> <tr> <td>a</td> <td>b</td> <td>c</td> </tbody> <tfoot> <tr> <th>a</th> <th>b</th> <th>c</th> </tr> </tfoot> </table> </div> </div> <div class="row"> <div class="col-xs-5"> <table class="table table-unruled"> .table .table-unruled <thead> <tr> <th>a</th> <th>b</th> <th>c</th> </tr> </thead> <tbody> <tr> <td>a</td> <td>b</td> <td>c</td> </tr> <tr> <td>a</td> <td>b</td> <td>c</td> </tbody> <tfoot> <tr> <th>a</th> <th>b</th> <th>c</th> </tr> </tfoot> </table> </div> <div class="col-xs-5 col-xs-offset-1"> <table class="table table-bordered table-unruled"> .table .table-bordered .table-unruled <thead> <tr> <th>a</th> <th>b</th> <th>c</th> </tr> </thead> <tbody> <tr> <td>a</td> <td>b</td> <td>c</td> </tr> <tr> <td>a</td> <td>b</td> <td>c</td> </tbody> <tfoot> <tr> <th>a</th> <th>b</th> <th>c</th> </tr> </tfoot> </table> </div> </div> </div>

在我的CSS:

.borderless tr td {
    border: none !important;
    padding: 0px !important;
}

在我的指示中:

<table class='table borderless'>
    <tr class='borderless' ....>

我没有把'borderless'放在td元素上。

测试并成功了! 所有的边框和衬垫都被完全剥离。

使用npm或cdn链接安装引导程序

<table class="table table-borderless">
<thead>
<tr>
  <th scope="col">#</th>
  <th scope="col">First</th>
  <th scope="col">Last</th>
  <th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
  <th scope="row">1</th>
  <td>Mark</td>
  <td>Otto</td>
  <td>@mdo</td>
</tr>
<tr>
  <th scope="row">2</th>
  <td>Jacob</td>
  <td>Thornton</td>
  <td>@fat</td>
  </tr>
  <tr>
  <th scope="row">3</th>
    <td colspan="2">Larry the Bird</td>
    <td>@twitter</td>
   </tr>
 </tbody>
</table>

使用此链接获取参考