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>
相关推荐
codezzzsleep38 分钟前
让个人智能体安全地接触外部资料
java·前端·安全
掘金安东尼1 小时前
文档不一致,会伤害 AI 编码智能体吗?智能体
前端
xurileidian9 小时前
第 24 篇 · 边玩边学Python · while 与死循环怎么退
服务器·前端·python
Highcharts.js10 小时前
Highcharts软件绘制图表:用数据构建可视化图形
前端·学习·信息可视化·数据分析·js·开发实战·highcharts
Hilaku12 小时前
2027 制药行业 ERP 系统架构选型笔记:从 GMP 合规追溯到动态 MCP 接入
前端·javascript·程序员
掘金安东尼13 小时前
人工智能AI
前端
kyriewen13 小时前
AI 面试官筛前端简历,先出局的不是写代码慢的
前端·面试·程序员
BigTopOne14 小时前
10 引用与借用:& 和 &mut
前端
粥里有勺糖14 小时前
视野修炼-技术周刊第139期 | AI 不会让时间变多
前端·github·ai编程
码哥字节14 小时前
Remotion Skills:用 React 代码做视频,简直太爽了
react.js