【问题标题】:Tailwind Config顺风配置
【发布时间】:2021-05-30 14:48:50
【问题描述】:

请不要烤我。

我尝试在顺风时启用暗模式。文档说我需要在我的配置中设置它。

这就是我的工作

npm install tailwindcss@latest postcss@latest autoprefixer@latest

然后我制作配置文件

npx tailwindcss init

把这段代码放进去

module.exports = {
  purge: [],
  presets: [],
  darkMode: "media", // or 'media' or 'class'
  ....
  ....
}

黑暗模式仍未开启,我该怎么办?

【问题讨论】:

    标签: css frameworks tailwind-css


    【解决方案1】:

    你试过了吗?

    // tailwind.config.js
    module.exports = {
      darkMode: 'class',
    }
    

    和 HTML

    <!-- Dark mode not enabled -->
    <html>
    <body>
      <!-- Will be white -->
      <div class="bg-white dark:bg-black">
        <!-- ... -->
      </div>
    </body>
    </html>
    
    <!-- Dark mode enabled -->
    <html class="dark">
    <body>
      <!-- Will be black -->
      <div class="bg-white dark:bg-black">
        <!-- ... -->
      </div>
    </body>
    </html>
    

    也尝试重建你的项目

    【讨论】:

    • 您好,谢谢您的回答!我已经尝试过了,但是如何重建项目?对不起,我已经用谷歌搜索了,但还是不明白:(
    • 如果您使用的是纯 HTML,那么您将无法重建您的应用程序。当您使用 React 或其他一些框架时需要它。对不起,如果我让你感到困惑:) 黑暗主题开始工作了吗?
    猜你喜欢
    • 2021-05-23
    • 2022-01-16
    • 2021-10-30
    • 2021-11-08
    • 2021-11-02
    • 2021-10-02
    • 2021-01-02
    • 2021-06-07
    • 2020-11-12
    相关资源
    最近更新 更多