Tailwindcss 웹사이트 메인 페이지에 나와있는 tailwind 정의
postcss
라이브러리의 플러그인
<div className='text-center'></div>
text-center
는 이미 css가 적용되어 있는 유틸리티 클래스// register.tsx
export default Register() {
return (
<form>
<button className='submit'>register</button>
</form>
)
}
// login.tsx
export default Login() {
return (
<form>
<button className='submit'>login</button>
</form>
)
}
postcss 적용 전
'register.css'
.submit {
color: red
}
'input.css'
.submit {
color: blue
}
적용 후
'register.module.css'
.submit {
color: red
}
'login.module.css'
.submit {
color: blue
}
브라우저에서 확인
.submit {
color: red
}
.submit_12a345 {
color: blue
}
'login.module.css'
.submit {
color: blue
}
.submit {
color: blue
-webkit-color: blue
-moz-color: blue
-ms-color: blue
}
tailwind.config.js
에서 커스터마이징// tailwind.config.js
const config = {
theme: {
extend: {
colors: {
border: "hsl(var(--border))",
}
}
}
}
hue/saturation/lightness
의 약자컬러/강도/밝기
.container {
background-color: hsl(360deg, 100%, 100%)
}
--변수명
같이 --
로 시작var()
함수에 인자로 사용: var(--변수명)
'전역 스코프'
:root {
color: var(--text3)
}
'지역 스코프'
.container {
color: var(--text3)
}
w-1
: 0.25rem = 4px<img class="w-16 md:w-32 lg:w-48" src="..." />
@media (min-width: 768px) {
img {
width: 128px
}
}
html {
font-size: 62.5%; /* changes a default 16px font size to 10px */
}
h1 {
font-size: 2.4rem; /* font size = 24px */
}
h2 {
font-size: 1.6rem; /* font size = 16px */
}
p {
font-size: 1.2rem; /* font size = 12px */
}