gpt4 book ai didi

html - 将 CSS 模块与 Modernizr(类名)一起使用

转载 作者:太空宇宙 更新时间:2023-11-04 01:40:20 25 4
gpt4 key购买 nike

Modernizr 将类添加到文档的 <html>标签,例如<html class="no-touchevents"> .

在我的代码中,我曾经写过这样的东西。

.style { background: green; }
.no-touchevents .style { background: red; }

因此,如果支持触摸,该元素将为绿色(OK),否则为红色(错误)。现在有了 CSS 模块,我的 .style类在单个文件中定义并被转换成这样的东西。

.xR23A { background: green; }
.hjTT7 .xR23A { background: red; }

如果我将我的类(class)包装在 :global 中条款,如果我理解正确,它应该保持不变。但是,这将适用于每个嵌套类,因此我将保留这一点。

.xR23A { background: green; }
.no-touchevents .style { background: red; }

我该如何解决这个问题以获得所需的解决方案?这就是我所追求的。

.xR23A { background: green; }
.no-touchevents .xR23A { background: red; }

最佳答案

您应该能够使用 global 的 paren 版本来仅容纳 modernizr 部分。

a.

.style { background: green; }
:global(.no-touchevents) .style { background: red; }

关于html - 将 CSS 模块与 Modernizr(类名)一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45494816/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com