我尝试使用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 结果: