css - 第一个 child CSS 表格的麻烦

标签 css css-tables

我已经看到了一些关于第一个 child 的问题,但我似乎无法解决任何问题。 我有一个表格,希望第一列全部为粗体,但其余文本为正常。

关于我的表:

div.article table{ 
    /* formatting stuff */
}

div.article table th {
    /* formatting */
}

div.article table tr {
    /* more formatting. I've got a funky looking table. */
}

然后我尝试:

div.article table tr:first-child {
    font-style:bold;
}   

不过好像没有影响。

有什么想法吗?我怀疑它真的很小,但我忽略了它。

最佳答案

你应该使用:

div.article table tr td:first-child {
  font-weight: bold;
}  

通过当前设置的方式,您指定作为 tablefirst-child 的行应该具有其 font-style 设置为 粗体。那里有 2 个问题,您应该使用 font-weight 而不是 font-style,并且您想要针对所有 td这是他们所在行的 first-child

关于css - 第一个 child CSS 表格的麻烦,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16494004/

相关文章:

css - 不使用图像的多个背景

javascript - 将多选更改为单选下拉列表

javascript - 无法使用javascript更新css中的图像位置

css - 无法在另一个旁边延长 div

twitter-bootstrap - Bootstrap 逆表和样式不正确

html - 用于 HTML 表格的错误 CSS

javascript - 如何在 HTML 页面解析后将行号放在源代码中?

html - 表格列宽与包含的数据一样窄?

html - CSS:为什么使用 float: left 打破 div 的高度?

html - 表格单元格内父 div 底部的子 div