【问题标题】:How to use nth-child selector in tailwindcss如何在 tailwindcss 中使用 nth-child 选择器
【发布时间】:2022-09-29 19:09:24
【问题描述】:

我想选择某个元素的所有其他元素,例如

<div class=\"parent\">
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</div>

我想在 css 中选择第二个和第四个 div 来做到这一点

.parent:nth-child(2n) { ... }

但在顺风中,我做了一些研究,但我仍然卡住了,有谁知道如何做这样的选择?

  • 但顺风--> tailwind 是 CSS,你可以编写自己的 CSS。不要试图找到 hacky 的解决方法,写 CSS

标签: css tailwind-css


【解决方案1】:

如果要从四个元素中选择第二个和第四个元素,可以使用even 伪选择器。这是文档https://tailwindcss.com/docs/hover-focus-and-other-states#even

【讨论】:

    【解决方案2】:
    猜你喜欢
    • 2013-04-04
    • 1970-01-01
    • 1970-01-01
    • 2011-09-03
    • 1970-01-01
    • 1970-01-01
    • 2017-10-26
    • 1970-01-01
    相关资源
    最近更新 更多