小编Dro*_*rag的帖子

Tailwind 类安装后不工作

我尝试使用CSS,我只是使用npm安装tailwindcss,然后构建css并提供output.css。但是,当我在按钮中使用 bg-black 类进行测试时,它仍然无法正常工作。

我使用的构建命令 tailwindcss -i ./src/style.css -o ./dist/output.css将其放入 package.json 中的脚本中

目录文件路径:
在此输入图像描述

src/style.css

@tailwind base;
@tailwind components;
@tailwind utilities;
Run Code Online (Sandbox Code Playgroud)

tailwind.config.js

    theme: {
      extend: {
        // ...
      },
    },
    plugins: [],
  }
Run Code Online (Sandbox Code Playgroud)

dist/index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="output.css">
    <title>Learn Tailwind</title>
</head>
<body>
    <div class="container">
        <button class="bg-black">Awesome</button>
    </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

浏览器中的 HTML 结果:

在此输入图像描述

html css tailwind-css

34
推荐指数
6
解决办法
13万
查看次数

标签 统计

css ×1

html ×1

tailwind-css ×1