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>
相关推荐
小沐°2 小时前
vue3-父子组件通信
前端·javascript·vue.js
铅笔侠_小龙虾2 小时前
Ubuntu 搭建前端环境&Vue实战
linux·前端·ubuntu·vue
yuhaiqun19892 小时前
发现前端性能瓶颈的巧妙方法:建立“现象归因→分析定位→优化验证”的闭环思维
前端·经验分享·笔记·python·学习·课程设计·学习方法
树叶会结冰2 小时前
TypeScript---循环:要学会原地踏步,更要学会跳出舒适圈
前端·javascript·typescript
唐叔在学习2 小时前
前端响应式设计实践:布局与字体自适应方案
前端·响应式设计
海云前端12 小时前
如果要设计一个开源的Code EditorSDK,你会向开发者暴露哪些API?
前端
Access开发易登软件2 小时前
Access 数据可视化:如何制作箱形图
前端·数据库·vba·access·access开发
Tiramisu20232 小时前
【VUE】删除 node_modules几种高效方法
前端·javascript·vue.js
钰fly2 小时前
Windows Forms开发工具与功能总结表
前端·c#