css - 给表格行加下划线但不加下划线

标签 css

我想看到如下截图所示的效果: enter image description here

这是我目前的代码:

table {
    border-collapse: collapse;
}

table tr td {
    border-bottom: 1px solid #000;
}

我不知道如何不给 TD 的内容加下划线,而只给空格加下划线。

最佳答案

我会为此使用 flexbox,如果你的浏览器兼容性没问题的话。

<html>

<table>
  <tr>
    <td>
      <div class="holder">
        <div class="label">FooBar</div>
        <div class="divider">
          &nbsp;
        </div>
        <div class="money">$1,000</div>
      </div>
    </td>
  </tr>
  <tr>
    <td>
      <div class="holder">
        <div class="label">FooBarFooBarFooBarFooBar</div>
        <div class="divider">
          &nbsp;
        </div>
        <div class="money">$1,000</div>
      </div>
    </td>
  </tr>
 </table>
</html>

风格:

.divider {
  border-bottom: 1px solid black;
  flex-grow: 1;  
}



.holder {
  display: flex;
  flex-direction: row;
  flex-wrap: no-wrap;
  width: 500px;
  justify-content: stretch;

}

.label, .money {
  flex-grow: 0;
  flex-basis: auto;
}

https://jsfiddle.net/pkyv8n5o/1/

enter image description here

关于css - 给表格行加下划线但不加下划线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57435517/

相关文章:

javascript - 在 JavaScript 中更改第 n 个子项的属性

image - 如何仅使用 CSS3 更改图像颜色(图像有灰色阴影)?

javascript - JQuery 仅在特定宽度下工作

css - 相对定位的文本被剪裁,即使有可见的溢出

css - FireFox 和 Chrome CSS 不同

html - 具有折叠 Angular 效果和动画的 CSS 按钮

css - 对齐宽度为 100% - 60px 的 div 中的文本

javascript - JQuery 中动态添加的页面未使用新样式更新我的页面

html - 始终将绝对定位的 div 置于交叉线上的中心?

php - 如何设置此 PHP 打印的 HTML 表单以保留在 <p> 标记内?