css - 如何在 .active 类之后获取下一个元素

标签 css class css-selectors listitem

<分区>

Trying to get next element after li.active class

我正在尝试使用 css 获取下一个元素在 .active 元素之后,获取 .active 类的元素是 'Lightslider 的第一个列表项。 '.

我试过下面的代码:

.lslide.active +  li:nth-child(1) {
  -ms-transform: scale(1.3);
  -webkit-transform: scale(1.3);
  transform: scale(1.3);
}

仅使用 CSS 是否可行?

谢谢。

最佳答案

只需使用 adjacent sibling selector + ,你不需要 nth-child 选择器:

.active + li {
  color: red;
}
<ul>
  <li class="active">Item</li>
  <li>Item</li>
  <li>Item</li>
</ul>

关于css - 如何在 .active 类之后获取下一个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40221386/

相关文章:

css - 我可以防止 :after pseudo-element from being read by screen readers?

python - 如何使用另一个类的方法装饰(monkeypatch...)Python 类?

c# - 如何解决泛型类 <T> 场景?

css - 选择两个元素之间的所有元素

css - 具有 sibling 的 parent 中类(class)的所有 child

css - 字体无法在 firefox 中加载,但可以在 chrome 中使用

html - 如何向图像跨度添加辅助工具提示?

jquery - 无法使用 CSS 设置 jQuery 标签的样式

excel - 类模块中是否需要 Me 关键字?

css - 高效和低效的 CSS 选择器(根据 Google、PageSpeed ...)