【问题标题】:In a table if the <tr> contains two <td> tags then it is possible to make one <td> tag as bold?在表中,如果 <tr> 包含两个 <td> 标签,那么是否可以将一个 <td> 标签设为粗体?
【发布时间】:2018-08-06 15:47:14
【问题描述】:

我想将第一个 td 标签设为粗体,并将其应用于整个表格。

<table>
  <tr>
    <td>Cell A</td>
    <td>Cell B</td>
  </tr>
</table>

【问题讨论】:

标签: html css html-table


【解决方案1】:

是的,您可以通过使用 css 属性字体粗细来做到这一点。 检查这个例子 => https://jsfiddle.net/wcx4Lej1/5/

<table>
 <tr>
  <td>Cell A</td>
  <td>Cell B</td>
 </tr>
</table>

td:first-child {
font-weight: bold;
}

如果你想将它应用到整个表格,你只需要在 css 上选择 tr 标签并将 font-weight 设置为粗体。

【讨论】:

  • 好吧,您只需要像我一样定位它们,但是您可以使用 css 选择器 nth child 例如 => td:nth-child(1) 这意味着您将定位第一个td 标签的元素。
  • 没问题。我很高兴我能帮上忙。享受编码!
猜你喜欢
  • 1970-01-01
  • 2015-02-11
  • 2011-04-30
  • 2021-10-18
  • 2016-02-26
  • 2021-01-11
  • 2012-10-30
  • 2013-03-23
  • 2012-04-16
相关资源
最近更新 更多