🖇️ [ 사이트_참고 ]
https://tailwindcss.com/docs/installation/using-vite
[설치]
1️⃣ Tailwind CSS 설치
npm install tailwindcss @tailwindcss/vite
2️⃣ vite.config.js 설정
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite' // ✨ 이 부분 추가
export default defineConfig({
plugins: [tailwindcss()], // ✨ 이 부분 추가
})
3️⃣ index.css에 Tailwind CSS 불러오기
📁 index.css
@import "tailwindcss";
위 내용 추가로 import 해주기
‼️ 추가 설치 내용
[오류 메시지] - Unknown at rule @tailwind
(1) Extension 설치
(2) Setting 값 변경
[ CSS ]
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tailwind 없이 버튼 스타일링</title>
<style>
.btn {
background-color: #3b82f6; /* Tailwind bg-blue-500 */
color: white; /* Tailwind text-white */
font-weight: bold; /* Tailwind font-bold */
padding: 8px 16px; /* Tailwind py-2 px-4 */
border-radius: 4px; /* Tailwind rounded */
border: none;
cursor: pointer;
transition: background-color 0.2s; /* Hover 효과 부드럽게 */
}
.btn:hover {
background-color: #1e40af; /* Tailwind hover:bg-blue-700 */
}
</style>
</head>
<body>
<button class="btn">클릭하세요</button>
</body>
</html>
[ tailwind ]
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
클릭하세요
</button>
div p:first-child {
color: #ef4444; /* Tailwind text-red-500 */
}
[tailwind] 예시<div class="space-y-4">
<p class="first:text-red-500">첫 번째 문단입니다.</p>
<p>두 번째 문단입니다.</p>
<p>세 번째 문단입니다.</p>
</div>
🔮 만약 <p\>
전체에 다 적용되기를 원할 경우에는, <p class="text-red-500"\>
세개 다 일일이 적용 시켜야 함, <p class="first:text-red-500"\>
이 코드를 두 번째 문단 <p\>
태그에 달았다면 적용되지 않음 first 가 맞는 경우에만 적용된다.html
파일에 넣어주기