标记前后的后代伪

时间:2019-06-11 13:04:04

标签: css

真的不可能针对子伪类吗?

我需要以某种方式设置第二个后代this.props.showMultiMatch || this.state.show::before类的样式。

datetime literals

例如,在这里我想在视觉上做出第二个::after(在“第一”列表项附近)

谢谢

::before
*::before {
  background-color: green;
}

*::after {
  background-color: red;
}

::after,
 ::before {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 5px;
  content: '';
  position: absolute;
  opacity: .7;
}

::before ::before {
  right: 2px;
}

1 个答案:

答案 0 :(得分:1)

由于有评论,当2个:before元素位于自身上方时,您可以移动其中之一。

例如。

ul:before {margin-top: -10px;} /* move 10px above LI:before */

OR

ul > li:first-child:before {margin-left: -10px;} /* move just 1st LIs :before */

这样,您需要浏览2个:before/after元素在同一位置(父级和第一个子级具有相同位置,等等)的所有位置

相关问题