Vite 安裝 Tailwind CSS入坑筆記

參考文檔
https://www.tailwindcss.cn/docs/installation
https://tailwindcss.com/docs/guides/vite#vue

npm create vite@latest
cnpm i
tailwindcss 
framework   use vue 
npm install -D tailwindcss postcss autoprefixer

執(zhí)行下面命令自動(dòng)創(chuàng)建配置文件

npx tailwindcss init -p

tailwind.config.js

需要修改content部分,

/** @type {import('tailwindcss').Config} */
export default {
  content: [
    "./index.html",
    "./src/**/*.{vue,js,ts,jsx,tsx}"

  ],
  theme: {
    extend: {},
  },
  plugins: [],
}


postcss.config.js

export default {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
}

src/style.css添加

@tailwind base;
@tailwind components;
@tailwind utilities;

如果是自己定義的項(xiàng)目,確保入口 main.ts 使用了import './style.css'
npm install

vscode提示 安裝 tailwind css intellisense
然后測試使用
如果字體顏色發(fā)生變化則代表成功。

<template>
    <div class="bg-[url('assets/imgs/bg.jpg')] bg-cover bg-center h-screen text-white p-5 flex overflow-hidden">
        <!-- 左  -->
        <div>
<div class="text-red-600 text-3xl">hellow world</div>

        </div>
        <!-- 中  -->
        <div></div>
        <!-- 右 -->
        <div></div>
    </div>
</template>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容