html - 处理表格内的底线

标签 html css

我正在尝试处理表格内的底线(我想将它们向右切一点)

enter image description here

这是我的表格代码:

<table class="reportTable">
     <thread>
          <tr>
                <th>firstColumn</th>
                <th>secondColumn</th>
                <th>thirdColumn</th>
          </tr>
     </thread>
     <tbody>
          <tr>
               <td>1</td>
               <td>2</td>
               <td>3</td> 
          </tr>
          <tr>
               <td>11</td>
               <td>22</td>
               <td>33</td> 
          </tr>
          <tr>
               <td>111</td>
               <td>222</td>
               <td>333</td> 
          </tr>
     </tbody>
</table>

这是我的 CSS 代码:

.reportTable th,td{
      border-bottom: 1px solid #E7E7E7;
      border-right:16px solid transparent;

 }

最佳答案

您可以为表格添加 border-spacing 并将其相对于负向左放置以将其推回其原始位置。

http://jsfiddle.net/hyn1db04/3/

<table class="reportTable">
 <thread>
      <tr>
            <th>firstColumn</th>
            <th>secondColumn</th>
            <th>thirdColumn</th>
      </tr>
 </thread>
 <tbody>
      <tr>
           <td>1</td>
           <td>2</td>
           <td>3</td> 
      </tr>
      <tr>
           <td>11</td>
           <td>22</td>
           <td>33</td> 
      </tr>
      <tr>
           <td>111</td>
           <td>222</td>
           <td>333</td> 
      </tr>
 </tbody>

CSS

.reportTable {
border-spacing: 30px 0;
}
.reportTable th, .reportTable td {
border-bottom: 1px solid #E7E7E7;
position: relative;
left: -30px;
}

编辑: 或者,您可以这样做:http://jsfiddle.net/m021e4gh/8/

.reportTable th,td {
border-bottom: 1px solid #E7E7E7;
}

table td + td, table th + th { 
position: relative;
left: 30px; 
}

table td + td + td, table th + th + th { 
position: relative;
left: 60px; 
}

如果需要,请添加宽度。

关于html - 处理表格内的底线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26679635/

相关文章:

html - Bootstrap .row类的正确用法

jquery - 如何在 div 中将不同大小的幻灯片图像居中

html - 如何创建始终可见的页脚?

css - 在SASS中展开之前的路径

jquery - 使一些元素不可选择 jquery ui

javascript - jQuery 选择具有相同 ID 的所有项目

html - 如何在 XSLT 中锚定标记?

html - li 来自图像/图标

html - 3 Column Layout-尝试在css框架之前掌握纯布局

javascript - 如何通过 jQuery 混合使用数字和其他 div 高度来设置 div 的高度?