CSS3 - 在另一个元素之后选择元素

Mr *_*kél 1 css selector

CSS3 是否可以选择紧随其后的元素?如果我有,例如:

<div>
  <a class="a">One</a>
  <a class="b">Two</a>
  <a class="c">Three</a>
  <a class="b">Four</a>
</div>
Run Code Online (Sandbox Code Playgroud)

我只想选择位于 class="a" 锚点之后的 class="b" 锚点。所以我希望选择“二”锚点而不是“四”锚点。

这在 CSS3 中可能吗?如果不能的话,用 jQuery 可以吗?(不过,我更喜欢 CSS)。

rin*_*t.6 5

为此,您不需要 CSS 3,CSS 2.1 中已经可以实现!:)

使用相邻同级选择器 +

.a + .b {
   /* styles */
}
Run Code Online (Sandbox Code Playgroud)