HTML 表格 td 左边框颜色不随 rowspan 更新

标签 html css

我有带 rowspan 的 HTML 表格,我想 td 使用不同的左边框颜色

HTML Code;

<table class="table">
  <tr>
    <td class ="fail-td" rowspan="2">Detail</td>
    <td class ="fail-td">Data 1</td>
    <td class="event">Event</td>
  </tr>
  <tr> <td  class ="success-td">Data 2</td></tr>

</table> 


Snippet:



.fail-td {
    border-left: 4px solid #d9534f  !important;
}
.success-td {
    border-left: 4px solid #5cb85c !important;
}

预期输出为 rowspan 第二行 td 左边框为绿色 但结果是 td 左边框为红色 enter image description here

最佳答案

设置 fail-td class name of second td of data 1 value

.fail-td {
  border-left: 4px solid #d9534f !important;
}

.success-td {
  border-left: 4px solid #5cb85c !important;
}
<table class="table">
  <tr>
    <td class="fail-td" rowspan="2">Detail</td>
    <td class="fail-td">Data 1</td>
    <td class="event">Event</td>
  </tr>
  <tr>
    <td class="success-td">Data 2</td>
  </tr>

</table>

关于HTML 表格 td 左边框颜色不随 rowspan 更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46886426/

相关文章:

javascript - 如果从上下文菜单调用,Chrome getSelection 不工作

c# - HTML 选择器库

jquery - 如何在页脚处停止固定位置滚动

javascript - HTML .style 属性是否与 Safari 浏览器完全兼容?

html - CSS 网格中的固定标题

css - 返回 CSS 动画起始位置

html - CSS 文件在 Safari 中有效,但在 Google Chrome 或 Firefox 中无效

html - Bootstrap 3 与 Bootstrap 4

jquery - $(window).scrollTop() 与 material.min.css 一起使用时返回 0

javascript - 将 div CSS 属性绑定(bind)到 Javascript 对象