css3 选择器,第 n 个 child 递增 1

标签 css css-selectors

我正在使用 css3 选择器来选择不同的 child 。是他们的替代方案而不是硬编码

.checkout_main .check_tr th:nth-child(1){
    width:50px;padding-left:10px;
}
.check_tr th:nth-child(2){
    width:300px;padding-left:10px;
}
.check_tr th:nth-child(3){
    width:50px;padding-left:10px;
}
.check_tr th:nth-child(4){
    width:100px;padding-left:10px;
}

最佳答案

有两种选择

You can use odd even
:nth-child(odd)
{
  width: 100px;
}

:nth-child(even)
{
  width:200px; 
}

另一种方法是您必须制定 an+b 。然后就可以了,让我知道你的 html。我会试着告诉你 an+b 形式。

关于css3 选择器,第 n 个 child 递增 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25074028/

相关文章:

css - 将 DIV 置于绝对 DIVS 下方(页脚)

javascript - CasperJS/SpookyJS css 选择器存在且不存在

html - 伪类 :last-child weirdness

JQuery:如何在 $(this) 中找到名为 "apples"的输入?

javascript - 似乎无法让 '.focus();' 元素工作...

html - @font-face 替代字体大小

javascript - 通过 CDN 加载文件 vs 将所有 CSS/JS 压缩到一个文件

javascript - 在悬停事件中更改图像时如何避免新请求?

css - 如何更有效地组织这些 CSS 选择器?我希望 CSS 选择器应用于也分配了 id 的元素

CSS 选择器 li :hover for only when none of its child is hovered