代码之家  ›  专栏  ›  技术社区  ›  Vpa

仅引导中的表边框和列边框

  •  0
  • Vpa  · 技术社区  · 6 年前

    我想要一张像下面这样的桌子,只有桌子 outline_border column border

    enter image description here

    How I achieve so far:
    

    enter image description here

    我怎样才能得到一个有边框和列边框的表,但不在一行中。我用了引导CSS。

    如果我用桌子上课 table-borderless outline-border ,但我希望列边框在表中

    I try like this questions

    请在下面播放:

    table {
        border:1px solid black;
        border-collapse: collapse;
    }
    table tr {
      border-left: 1px solid #000;
      border-right: 1px solid #000;
    }
    
    table td {
        border-left: 1px solid #000;
        border-right: 1px solid #000;
    }
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"/>
    
    <table class="table table-small">
      <thead>
        <tr>
          <th>#</th>
          <th>Name</th>
          <th>Col1</th>
          <th>Col2</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>1</td>
          <td>name</td>
          <td>123</td>
          <td>456</td>
        </tr>
        <tr>
          <td>2</td>
          <td>name2</td>
          <td>xyz</td>
          <td>abc</td>
        </tr>
        <tr>
          <td>1</td>
          <td>name</td>
          <td>123</td>
          <td>456</td>
        </tr>
        <tr>
          <td>2</td>
          <td>name2</td>
          <td>xyz</td>
          <td>abc</td>
        </tr>
        <tr>
          <td>1</td>
          <td>name</td>
          <td>123</td>
          <td>456</td>
        </tr>
        <tr>
          <td>2</td>
          <td>name2</td>
          <td>xyz</td>
          <td>abc</td>
        </tr>
        <tr>
          <td>1</td>
          <td>name</td>
          <td>123</td>
          <td>456</td>
        </tr>
        <tr>
          <td>2</td>
          <td>name2</td>
          <td>xyz</td>
          <td>abc</td>
        </tr>
      </tbody>
    </table>
    2 回复  |  直到 6 年前
        1
  •  3
  •   Gerard    6 年前

    !important .

    编辑 :删除表格单元格之间的水平线。

    .table {
      border: 1px solid black;
    }
    
    .table thead th {
      border-top: 1px solid #000!important;
      border-bottom: 1px solid #000!important;
      border-left: 1px solid #000;
      border-right: 1px solid #000;
    }
    
    .table td {
      border-left: 1px solid #000;
      border-right: 1px solid #000;
      border-top: none!important;
    }
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" />
    
    <table class="table table-small">
      <thead>
        <tr>
          <th>#</th>
          <th>Name</th>
          <th>Col1</th>
          <th>Col2</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>1</td>
          <td>name</td>
          <td>123</td>
          <td>456</td>
        </tr>
        <tr>
          <td>2</td>
          <td>name2</td>
          <td>xyz</td>
          <td>abc</td>
        </tr>
        <tr>
          <td>1</td>
          <td>name</td>
          <td>123</td>
          <td>456</td>
        </tr>
        <tr>
          <td>2</td>
          <td>name2</td>
          <td>xyz</td>
          <td>abc</td>
        </tr>
        <tr>
          <td>1</td>
          <td>name</td>
          <td>123</td>
          <td>456</td>
        </tr>
        <tr>
          <td>2</td>
          <td>name2</td>
          <td>xyz</td>
          <td>abc</td>
        </tr>
        <tr>
          <td>1</td>
          <td>name</td>
          <td>123</td>
          <td>456</td>
        </tr>
        <tr>
          <td>2</td>
          <td>name2</td>
          <td>xyz</td>
          <td>abc</td>
        </tr>
      </tbody>
    </table>
        2
  •  0
  •   Vpa    6 年前

    对于上面的评论,我的问题是,我可以实现下面我想要的,但是我必须在任何地方使用内联CSS。除了内联CSS,还有更好的方法吗

    .table {
      border: 1px solid black;
    }
    
    .table thead th {
      border-top: 1px solid #000!important;
      border-bottom: 1px solid #000!important;
      border-left: 1px solid #000;
      border-right: 1px solid #000;
    }
    
    .table td {
      border-left: 1px solid #000;
      border-right: 1px solid #000;
      border-top: none!important;
    }
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" />
    
    <table class="table table-small">
      <thead>
        <tr>
          <th>#</th>
          <th>Name</th>
          <th>Col1</th>
          <th>Col2</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>1</td>
          <td>name</td>
          <td>123</td>
          <td>456</td>
        </tr>
        <tr>
          <td>2</td>
          <td>name2</td>
          <td>xyz</td>
          <td>abc</td>
        </tr>
        <tr>
          <td>1</td>
          <td>sub-total</td>
          <td style="border-bottom: 1px solid #000;border-top: 1px solid #000!important;">123</td>
          <td style="border-bottom: 1px solid #000;border-top: 1px solid #000!important">456</td>
        </tr>
        <tr>
          <td>2</td>
          <td>name2</td>
          <td>xyz</td>
          <td>abc</td>
        </tr>
        <tr>
          <td>1</td>
          <td>name</td>
          <td>123</td>
          <td>456</td>
        </tr>
        <tr>
          <td>2</td>
          <td>name2</td>
          <td>xyz</td>
          <td>abc</td>
        </tr>
        <tr>
          <td>1</td>
          <td>name</td>
          <td>123</td>
          <td>456</td>
        </tr>
        <tr style="border-top: 1px solid #000!important">
          <td>##</td>
          <td>Total</td>
          <td>xyz</td>
          <td>abc</td>
        </tr>
      </tbody>
    </table>
        3
  •  0
  •   Muhammad Tariq    4 年前

    只有通过在head标签中添加这些样式才能做到这一点

    .invoice-table {
            border: 1px solid black;
        }
    
        .invoice-table thead th {
            border: 1px solid #000!important;
    
        }
    
        .invoice-table td {
            border: 1px solid #000;
    
        }
    

    导入:为每个tr添加行,我们可以简单地添加到

    <tr style="border-top: 1px solid #000!important">