reactjs - @apply 在 tailwindcss 中不工作 |全局 css 文件中的 Next.js

标签 reactjs next.js tailwind-css

@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base{
body {
    @apply bg-[#06202A] text-grey-300; 
}
}

@apply 没有在带有 tailwindcss 的 Nextjs 中唤醒 css 全局文件我也使用模式来 jit 但仍然无法工作,需要帮​​助...... enter image description here

最佳答案

@apply 是一种在通用 CSS 文件中使用通过 Tailwind 指令制作的自定义 CSS 的方法。因此,bg-[#06202A]必须在使用前声明。

You neeed to pre defined in your TailwindCSS file before use it. so these could be solution.

解决方案1

@layer base{
   body {
       --body-bg-color: '#06202A';
       @apply bg-var(--body-bg-color) text-grey-300; 
   }
}

解决方案2

body {
   --body-bg-color:'#06202A';
   --tw-text-opacity: 1;
   background-color: var(--body-bg-color);
   color: rgba(209, 213, 219, var(--tw-text-opacity));
}

此外,以下 link会对你有所帮助。 祝你好运,编码愉快!

关于reactjs - @apply 在 tailwindcss 中不工作 |全局 css 文件中的 Next.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67985622/

相关文章:

android - 如何仅向中间件授予 webview 应用程序的访问权限 - next.js

single-page-application - Next.JS单页应用程序?

css - 带有 tailwindcss 的特殊网格布局

html - 显示超出下拉 div 的图像

javascript - 如何在 React (JSX) 中清除/重置状态内的数组

reactjs - Stripe 参数_invalid_integer

javascript - 组件未重新加载但状态随 useState 发生变化

javascript - React - 更改组件 onClick 的样式并重置

css - [NextJs/TailwindCSS] : css classes are missing in production

javascript - 在 Vite2 中,如何在 tailwind.config.js 中导入 ESModule