|
1 | 1 | <div class="site-header"> |
2 | 2 | <nav class="site-nav"> |
| 3 | + <button class="nav-toggle" aria-label="메뉴 열기" aria-expanded="false"> |
| 4 | + <span class="hamburger"></span> |
| 5 | + </button> |
3 | 6 | <div class="nav-links"> |
4 | 7 | <a href="/" class="nav-link">홈</a> |
5 | 8 | <a href="/organizers/" class="nav-link">운영진</a> |
|
13 | 16 | </nav> |
14 | 17 | </div> |
15 | 18 |
|
| 19 | +<script> |
| 20 | + document.addEventListener('DOMContentLoaded', function() { |
| 21 | + const navToggle = document.querySelector('.nav-toggle'); |
| 22 | + const navLinks = document.querySelector('.nav-links'); |
| 23 | + |
| 24 | + navToggle.addEventListener('click', function() { |
| 25 | + const isExpanded = navToggle.getAttribute('aria-expanded') === 'true'; |
| 26 | + navToggle.setAttribute('aria-expanded', !isExpanded); |
| 27 | + navLinks.classList.toggle('nav-open'); |
| 28 | + }); |
| 29 | + |
| 30 | + // 메뉴 링크 클릭 시 메뉴 닫기 |
| 31 | + navLinks.querySelectorAll('.nav-link').forEach(link => { |
| 32 | + link.addEventListener('click', () => { |
| 33 | + navToggle.setAttribute('aria-expanded', 'false'); |
| 34 | + navLinks.classList.remove('nav-open'); |
| 35 | + }); |
| 36 | + }); |
| 37 | + }); |
| 38 | +</script> |
| 39 | + |
16 | 40 | <style> |
17 | 41 | .site-header { |
18 | | - background-color: #0078d7; /* Microsoft .NET 색상 */ |
| 42 | + background-color: #0078d7; |
19 | 43 | padding: 12px 20px; |
20 | 44 | margin-bottom: 20px; |
21 | 45 | } |
|
25 | 49 | margin: 0 auto; |
26 | 50 | display: flex; |
27 | 51 | align-items: center; |
28 | | - justify-content: space-between; |
| 52 | + justify-content: center; |
29 | 53 | } |
30 | 54 |
|
31 | | -.nav-logo { |
32 | | - display: flex; |
33 | | - align-items: center; |
34 | | - text-decoration: none; |
| 55 | +/* 햄버거 버튼 - 기본적으로 숨김 */ |
| 56 | +.nav-toggle { |
| 57 | + display: none; |
| 58 | + background: none; |
| 59 | + border: none; |
| 60 | + cursor: pointer; |
| 61 | + padding: 10px; |
| 62 | + z-index: 100; |
| 63 | +} |
| 64 | + |
| 65 | +.hamburger { |
| 66 | + display: block; |
| 67 | + width: 24px; |
| 68 | + height: 3px; |
| 69 | + background-color: white; |
| 70 | + position: relative; |
| 71 | + transition: background-color 0.3s ease; |
| 72 | +} |
| 73 | + |
| 74 | +.hamburger::before, |
| 75 | +.hamburger::after { |
| 76 | + content: ''; |
| 77 | + position: absolute; |
| 78 | + width: 24px; |
| 79 | + height: 3px; |
| 80 | + background-color: white; |
| 81 | + left: 0; |
| 82 | + transition: transform 0.3s ease; |
| 83 | +} |
| 84 | + |
| 85 | +.hamburger::before { |
| 86 | + top: -8px; |
| 87 | +} |
| 88 | + |
| 89 | +.hamburger::after { |
| 90 | + top: 8px; |
| 91 | +} |
| 92 | + |
| 93 | +/* 햄버거 -> X 애니메이션 */ |
| 94 | +.nav-toggle[aria-expanded="true"] .hamburger { |
| 95 | + background-color: transparent; |
35 | 96 | } |
36 | 97 |
|
37 | | -.logo-img { |
38 | | - height: 40px; |
39 | | - width: auto; |
40 | | - transition: opacity 0.2s ease; |
| 98 | +.nav-toggle[aria-expanded="true"] .hamburger::before { |
| 99 | + transform: rotate(45deg) translate(5px, 6px); |
41 | 100 | } |
42 | 101 |
|
43 | | -.logo-img:hover { |
44 | | - opacity: 0.8; |
| 102 | +.nav-toggle[aria-expanded="true"] .hamburger::after { |
| 103 | + transform: rotate(-45deg) translate(5px, -6px); |
45 | 104 | } |
46 | 105 |
|
47 | 106 | .nav-links { |
|
64 | 123 | border-radius: 5px; |
65 | 124 | } |
66 | 125 |
|
67 | | -.nav-external { |
68 | | - border: 1px solid rgba(255, 255, 255, 0.5); |
69 | | - border-radius: 5px; |
70 | | -} |
71 | | - |
| 126 | +/* 모바일 반응형 */ |
72 | 127 | @media (max-width: 768px) { |
73 | 128 | .site-nav { |
74 | | - flex-direction: column; |
75 | | - gap: 15px; |
| 129 | + justify-content: flex-end; |
| 130 | + position: relative; |
76 | 131 | } |
77 | 132 |
|
78 | | - .nav-links { |
79 | | - flex-direction: row; |
80 | | - flex-wrap: wrap; |
81 | | - justify-content: center; |
82 | | - } |
83 | | - |
84 | | - .nav-link { |
85 | | - margin: 5px 8px; |
| 133 | + .nav-toggle { |
| 134 | + display: block; |
86 | 135 | } |
87 | | -} |
88 | 136 |
|
89 | | -@media (max-width: 480px) { |
90 | 137 | .nav-links { |
| 138 | + position: absolute; |
| 139 | + top: 100%; |
| 140 | + left: 0; |
| 141 | + right: 0; |
| 142 | + background-color: #ffffff; |
91 | 143 | flex-direction: column; |
| 144 | + padding: 0; |
| 145 | + max-height: 0; |
| 146 | + overflow: hidden; |
| 147 | + transition: max-height 0.3s ease, padding 0.3s ease; |
| 148 | + box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15); |
| 149 | + border-top: 3px solid #0078d7; |
| 150 | + z-index: 99; |
92 | 151 | } |
93 | | - |
| 152 | + |
| 153 | + .nav-links.nav-open { |
| 154 | + max-height: 500px; |
| 155 | + padding: 15px 0; |
| 156 | + } |
| 157 | + |
94 | 158 | .nav-link { |
95 | | - margin: 5px 0; |
| 159 | + margin: 0; |
| 160 | + padding: 12px 20px; |
| 161 | + width: 100%; |
| 162 | + text-align: center; |
| 163 | + box-sizing: border-box; |
| 164 | + color: #0078d7; |
| 165 | + border-bottom: 1px solid #e0e0e0; |
| 166 | + } |
| 167 | + |
| 168 | + .nav-link:last-child { |
| 169 | + border-bottom: none; |
| 170 | + } |
| 171 | + |
| 172 | + .nav-link:hover { |
| 173 | + background-color: #f0f7ff; |
| 174 | + border-radius: 0; |
96 | 175 | } |
97 | | -} |
98 | 176 | } |
99 | 177 | </style> |
0 commit comments