tailwind.config.js 파일을 통해 다크 모드 설정시 적용이 되지 않습니다.
353
8 câu hỏi đã được viết
[tailwind.config.js]
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./src/**/*.{html,js}'],
darkMode: 'selector',
};
[practice-test.html]
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tailwind CSS</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-white dark:bg-gray-900 dark:text-white">
<main
class="container max-w-5xl mx-auto min-h-screen flex items-center justify-center"
>
<div class="flex flex-col items-center">
<h1 class="font-extrabold text-3xl">Tailwind CSS 다크모드</h1>
<p class="mt-4">이 페이지는 다크 모드를 지원합니다.</p>
<button
id="darkmode_btn"
class="bg-blue-500 px-4 py-2 rounded-md text-white mt-4"
>
다크 모드 전환
</button>
<div
class="px-10 py-6 bg-white rounded-md shadow-md mt-20 dark:bg-gray-800"
>
<p>이 박스는 다크 모드에서 배경이 어두운 색으로 변합니다.</p>
</div>
</div>
</main>
<script>
document.querySelector('#darkmode_btn').addEventListener('click', () => {
document.documentElement.classList.toggle('dark');
});
</script>
</body>
</html>
tailwind.config.js 의 경로는 아래 스크린샷으로 첨부하였습니다.

제가 무슨 설정을 빠트린건지 명확히는 모르겠는데 <head> 태그 내부에 <script> 태그로 아래와 같이 설정하면 버튼을 클릭했을 때 다크모드와 원래 상태로 정상적으로 토글이 되는데 tailwind.config.js 로 설정만 하면 토글이 안되네요 모든 페이지에 다크모드를 설정하기 위해서는 tailwind.config.js 를 통해서 다크 모드 활성화를 하는 것이 좋을 것 같아서 질문 남깁니다! 좋은 강의 감사드립니다.
tailwind.config = { // darkMode: 'media', // 운영 체제의 모드에 맞게 설정 darkMode: 'selector', // 수동으로 설정 };
Câu trả lời 1
0
CDN으로 tailwind 를 설치했을 경우에는 tailwind.config 설정을 해당 파일 안에 하셔야돼요~!
tailwind.config.js 파일은 tailwind intellisense를 위한 파일입니다.
Dark Mode 설정 회차를 한번 더 보시는 것을 권장드립니다.
하
0
17
0
console.log 안찍힘
0
34
2
Reducer undefined로 나오는 문제의 건
0
52
2
zod 관련
0
37
1
100% 완료가 안됩니다.
0
44
1
단체카톡방은 어디에..
1
44
0
회원 가입 폼 실습에서 value? 개념이 헷갈려요
0
57
2
교안자료 다운로드 방법 문의
0
35
1
자료 관련 질문?
0
42
1
수업 소스가 강의 시작전 코드만 있는게 맞나요?
0
56
2
useState는 왜 state를 setter를 통해 변경해야 하는지 궁금해요.
0
70
2
tailwindcss v4.1 에서의 script 사용에 대해 궁금한 점이 있습니다.
1
162
1
확장 프로그램 설치 및 최적화 버전 문의
1
177
2
tailwindcss 와 ai tool
0
143
1
tailwindcss 4.1 docs에서는 container가 목록에서 안보이네요
0
133
2
quasar와 tailwind 조합에 관한 질문
0
146
1
실습에 사용되는 이미지
0
192
2
모바일 사이즈에 대해 질문있습니다.
0
132
1
nested 리스트일때 <ul> bullet 스타일 바꾸는 방법
0
268
2
via.placeholder.com 오류
0
943
2
빈 화면에서 tail 만 쳤을때 팝업도움말 나오게 하는 법 알려주세요.
0
177
2
수강평 이벤트
0
195
2
font-weight가 왜 적용이 안될까요?
0
492
3
스니펫 관련질문
0
184
1

