第一个孩子不在tbody工作?

时间:2018-02-12 16:10:22

标签: css sass css-selectors

我试图在我的体内选择第一个td.is-active。 .is-active风格被广泛接受,但是不可能将半径添加到第一个(并且只有第一个).is-active。

Full code here.

或者只是我的SCSS:

td {
      &.is-active {
            background-color: $color5;

            &:first-child {
                border-bottom-left-radius: 10px;
                border-top-left-radius: 10px;
        }
       }
}

一个想法?感谢。

1 个答案:

答案 0 :(得分:1)

CSS属性不是累积的,不支持子选择。 td.is-active:first-child选择.is-active组中的第一个元素。如果它具有.is-active类,它将选择第一个td,并且没有td匹配此条件。

td:first-child将始终选择第一个td,无论其类别如何。

您正在寻找:first-of-class selector,但遗憾的是,它并不存在。