小编ejp*_*low的帖子

如何创建一个使用带有 tailwindcss 的奇子伪选择器的类

我在课堂上使用奇数子伪选择器时遇到一些困难。odd:bg-blue-200 内联使用时效果很好。但我想提取这种样式,以便在给定类 .tr 时,我的所有表行都具有这种样式。我一直在查看文档,但解决方案一直困扰着我。我希望这里有人可以提供帮助。

到目前为止,我已经尝试过:

.tr:odd {
  @apply bg-blue-200;
}
Run Code Online (Sandbox Code Playgroud)

@variants odd {
  .tr {
    @apply bg-blue-200;
  }

}
Run Code Online (Sandbox Code Playgroud)

在 tailwind.config.js 中,我添加了 backgroundColor 变体:

variants: {
'backgroundColor': ['responsive', 'odd', 'hover']
},
Run Code Online (Sandbox Code Playgroud)

css tailwind-css

6
推荐指数
1
解决办法
8300
查看次数

标签 统计

css ×1

tailwind-css ×1