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>
相关推荐
VT.馒头2 分钟前
【力扣】2695. 包装数组
前端·javascript·算法·leetcode·职场和发展·typescript
css趣多多14 分钟前
一个UI内置组件el-scrollbar
前端·javascript·vue.js
C澒34 分钟前
前端整洁架构(Clean Architecture)实战解析:从理论到 Todo 项目落地
前端·架构·系统架构·前端框架
C澒40 分钟前
Remesh 框架详解:基于 CQRS 的前端领域驱动设计方案
前端·架构·前端框架·状态模式
Charlie_lll44 分钟前
学习Three.js–雪花
前端·three.js
onebyte8bits1 小时前
前端国际化(i18n)体系设计与工程化落地
前端·国际化·i18n·工程化
C澒1 小时前
前端分层架构实战:DDD 与 Clean Architecture 在大型业务系统中的落地路径与项目实践
前端·架构·系统架构·前端框架
BestSongC1 小时前
行人摔倒检测系统 - 前端文档(1)
前端·人工智能·目标检测
lbb 小魔仙1 小时前
【HarmonyOS实战】React Native 鸿蒙版实战:Calendar 日历组件完全指南
react native·react.js·harmonyos
0思必得02 小时前
[Web自动化] Selenium处理滚动条
前端·爬虫·python·selenium·自动化