【问题标题】:Not able to bold first column in table. I have tried the normal methods无法加粗表中的第一列。我已经尝试了正常的方法
【发布时间】:2019-06-10 22:08:06
【问题描述】:

我需要将我正在创建的表格中的第一列(tbody 标记内)加粗。由于某种原因,正常的方法不起作用。我已经尝试过标签和字体粗细:粗体以及第一个孩子。我怀疑它与通过 TS 中的函数生成的行有关?我试图在函数中将文本设置为粗体,但似乎也无法做到这一点。我对此很陌生,所以也许我只是缺少一些简单的东西?任何帮助将不胜感激!

顺便正常生成表格。

tbody:first-child {
  font-weight: bold;
}
<table class="table table-editable table-striped table-hover table-  sortable" style="width:100%">
  <thead class="thread-dark">
    <tr>
      <th style="width: 90px;">Team</th>
      <th style="width: 90px;">Category</th>
      <th style="width: 90px;">SWAG</th>
      <th style="width: 90px;">Completed</th>
      <th style="width: 90px;">Remaining</th>
      <th style="width: 90px;">% Over/ Under SWAG</th>
    </tr>
  </thead>
  <ng-template ngFor let-team [ngForOf]="gemEngineeringTeams">
    <tbody team-list-row [engineeringTeam]="team"></tbody>
  </ng-template>
</table>

【问题讨论】:

  • 您的选择器应该是:tbody tr td:first-child

标签: html css


【解决方案1】:

您正在寻找“任何tbody,它也是其父级的first-child”(tbody:first-child)。

您想查找任何td,它是 tbody 内的第一个孩子:

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

或者,如果您预计除了 td 之外可能还有 th,那么“tbody 内一行中的任何第一个子元素”:

tbody tr :first-child {
  font-weight: bold;
}

【讨论】:

    猜你喜欢
    • 2016-09-14
    • 2021-10-10
    • 1970-01-01
    • 2021-12-16
    • 2021-01-08
    • 2021-07-08
    • 2016-10-19
    • 1970-01-01
    • 2013-07-30
    相关资源
    最近更新 更多