admin管理员组文章数量:1296451
In my Tailwind.config.js from v3 I have this
screens: {
print: { raw: "print" },
screen: { raw: "screen" },
},
How can I convert that the new @theme {} style?
In my Tailwind.config.js from v3 I have this
screens: {
print: { raw: "print" },
screen: { raw: "screen" },
},
How can I convert that the new @theme {} style?
Share Improve this question edited Feb 12 at 6:25 DarkBee 15.6k8 gold badges72 silver badges116 bronze badges asked Feb 12 at 2:45 Ian VinkIan Vink 68.8k107 gold badges352 silver badges567 bronze badges2 Answers
Reset to default 0From v4 onwards, the @screen variant has been removed in the CSS-first configuration and replaced with @custom-variant
, which allows you to create any variant:
@custom-variant custom-screen (@media screen);
@custom-variant custom-print (@media print);
custom-screen:bg-blue-100 custom-print:bg-red-100
In CSS, you can use the @variant
directive to reference both the default and custom variants you create.
.my-element {
background-color: white;
@variant custom-screen {
background-color: blue;
}
@variant custom-print {
background-color: red;
}
}
- TailwindCSS @screen how to use
However, starting from TailwindCSS v4, the print
and orientation directives have been introduced by default.
hidden print:block portrait:bg-blue-100 landscape:bg-red-100
.my-element {
background-color: white;
@variant portrait {
background-color: blue;
}
@variant landscape {
background-color: red;
}
}
If the CSS-first settings are not appealing, there is an option to use the legacy JavaScript-based configuration through the @config
directive.
- TailwindCSS v4 is backwards compatible with v3
You can use the @custom-variant
directive like:
@custom-variant print (@media print);
@custom-variant screen (@media screen);
Though really, you don't need the print
one as it is built in to v4 already.
本文标签: tailwind cssHow can I convert print and screen to the new theme styleStack Overflow
版权声明:本文标题:tailwind css - How can I convert print: and screen: to the new @theme{} style? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741623808a2388966.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论