使用 css 为表格中的最后一个 td 设计样式 [英] Styling the last td in a table with css

查看:46
本文介绍了使用 css 为表格中的最后一个 td 设计样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在不使用特定 TD 上的 CSS 类的情况下设置表格中最后一个 TD 的样式.

I want to style the last TD in a table without using a CSS class on the particular TD.

<table>
  <tbody>
    <tr>
      <td>One</td>
      <td>Two</td>
      <td>Three</td>
      <td>Four</td>
      <td>Five</td>
    </tr>
  </tbody>
</table>

table td 
{ 
  border: 1px solid black;
}

我希望包含文本Five"的 TD 没有边框,但同样,我不想使用类.

I want the TD containing the text "Five" to not have a border but again, I do not want to use a class.

推荐答案

您可以使用相关规则:

table td + td + td + td + td {
  border: none;
}

这仅适用于未在运行时确定列数的情况.

This only works if the number of columns isn't determined at runtime.

这篇关于使用 css 为表格中的最后一个 td 设计样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆