react基础框架搭建4-tailwindcss配置:react+router+redux+axios+Tailwind+webpack

可以加速css编写速度

官方文档:

https://www.tailwindcss.cn/

复制代码
npm install tailwindcss 

1、初始化

复制代码
npx tailwindcss init -p

2、配置 tailwind.config.js:

在根目录创建此文件

复制代码
  module.exports = {
     content: [
       "./src/**/*.{js,jsx,ts,tsx}",
     ],
     theme: {
       extend: {},
     },
     plugins: [],
   }

3、在 src/index.css 中引入 Tailwind:

复制代码
 @tailwind base;
 @tailwind components;
 @tailwind utilities;

4、补充说明-tailwindcss简介

可以直接在 HTML 中使用一些类来快速构建样式,而无需编写自定义 CSS:bg-blue-500、text-center、p-4 等。

配置文件tailwind.config.js只可以设置自定义主题、颜色、间距、字体等。

使用:

复制代码
<div class="max-w-md mx-auto bg-white shadow-lg rounded-lg overflow-hidden">
    <div class="p-4">
        <h2 class="text-xl font-bold text-gray-800">标题</h2>
        <p class="text-gray-600">这是一个使用 Tailwind CSS 构建的示例卡片。</p>
        <button class="mt-4 bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-700">
            点击我
        </button>
    </div>
</div>
相关推荐
宸翰42 分钟前
uni-app 设置 Android 底部虚拟导航栏背景色
android·前端·uni-app
金色的暴发户1 小时前
一劳永逸解决Codex手机验证
前端·人工智能·开源
DanCheOo1 小时前
AI 应用的可观测性:你的 AI 系统在生产上到底表现怎么样
前端·openai
Hyyy2 小时前
流式渲染用react-markdown还是Vercel/Streamdown
前端
风中的小甜瓜2 小时前
ASP.NET Page 那点事
java·前端·asp.net
木西2 小时前
告别机械重复:使用 Node.js + Playwright 构建 24 小时全自动测试网领水脚本
前端·javascript·node.js
西柚小萌新2 小时前
【论文写作】--LaTeX详细入门教程2
前端·html
qdkfz2 小时前
JavaScript 如何解析 Outlook .msg 文件 —— @kenjiuno/msgreader
前端·javascript
LuckyDog阿祥3 小时前
卸载Microsoft Edge:EdgeRemover完整操作指南
前端·edge
zhangxingchao3 小时前
AI应用开发九:从 Hermes Agent 学长期记忆
前端·人工智能·后端