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>
相关推荐
用户69371750013845 小时前
Google 正在“收紧侧加载”:陌生 APK 安装或需等待 24 小时
android·前端
蓝帆傲亦5 小时前
Web 前端搜索文字高亮实现方法汇总
前端
用户69371750013845 小时前
Room 3.0:这次不是升级,是重来
android·前端·google
漫随流水6 小时前
旅游推荐系统(view.py)
前端·数据库·python·旅游
踩着两条虫7 小时前
VTJ.PRO 核心架构全公开!从设计稿到代码,揭秘AI智能体如何“听懂人话”
前端·vue.js·ai编程
jzlhll1238 小时前
kotlin Flow first() last()总结
开发语言·前端·kotlin
蓝冰凌9 小时前
Vue 3 中 defineExpose 的行为【defineExpose暴露ref变量】详解:自动解包、响应性与实际使用
前端·javascript·vue.js
奔跑的呱呱牛9 小时前
generate-route-vue基于文件系统的 Vue Router 动态路由生成工具
前端·javascript·vue.js
柳杉10 小时前
从动漫水面到赛博飞船:这位开发者的Three.js作品太惊艳了
前端·javascript·数据可视化