小编Ond*_*šek的帖子

如何更改单个表格行的边框颜色?

我试图通过更改单个行的边框颜色来突出显示表格行。这是我的 CSS:

    table { border-collapse: collapse;}

    td { min-width: 100px; border: 1px solid green; }

    .highlight td { border: 1px solid orange; }
Run Code Online (Sandbox Code Playgroud)

...这是我的 HTML:

<table>
    <tr>
        <td>1</td>
        <td>2</td>
    </tr>
    <tr class="highlight">
        <td>3</td>
        <td>4</td>
    </tr>
    <tr>
        <td>5</td>
        <td>6</td>
    </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

结果是这样的: 在此处输入图片说明

顶部边框保持绿色。我可以让它工作的唯一方法是更改​​ TD 元素 1 和 2 的边框底部颜色。有没有更优雅的解决方案?使用大纲属性并没有解决问题。谢谢!

html css html-table

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

css ×1

html ×1

html-table ×1