Skip to content

Commit c3328d5

Browse files
committed
Dropdown menu for mobile rendering
1 parent ef20a48 commit c3328d5

File tree

3 files changed

+73
-11
lines changed

3 files changed

+73
-11
lines changed

header.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ <h3 id="h3head" class="header2-title" >Bringing Quantum Technologies to HEP</h3>
88
</div>
99

1010
</div>
11-
<nav>
12-
<ul>
11+
<nav class="navbar">
12+
<ul class="nav-links">
1313
<li><a href="index.html">Home</a></li>
1414
<li><a href="projects.html">Projects</a></li>
1515
<li><a href="peoples.html">Peoples</a></li>
1616
<li><a href="future.html">Future Ideas</a></li>
1717
<li><a href="https://github.com/Quantum4HEP">Github Repository</a></li>
1818
</ul>
19+
<button class="menu-toggle" aria-label="Open menu"></button>
1920
</nav>
2021
</header>

script.js

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ async function loadHeader() {
2525

2626
lastScrollTop = scrollTop;
2727
});
28+
document.querySelector(".menu-toggle").addEventListener("click", function () {
29+
document.querySelector(".nav-links").classList.toggle("show");
30+
});
2831
} catch (error) {
2932
console.error("Error loading header:", error);
3033
}

styles.css

+67-9
Original file line numberDiff line numberDiff line change
@@ -91,23 +91,23 @@ header h1 {
9191
color: #fff;
9292
}
9393

94-
nav ul {
94+
.nav-links {
9595
list-style: none;
9696
display: flex;
9797
justify-content: center;
9898
}
9999

100-
nav ul li {
100+
.nav-links li {
101101
margin: 0 1rem;
102102
}
103103

104-
nav ul li a {
104+
.nav-links li a {
105105
color: #fff;
106106
text-decoration: none;
107107
font-weight: bold;
108108
}
109109

110-
nav ul li a:hover {
110+
.nav-links li a:hover {
111111
color: #ffb000;
112112
}
113113

@@ -197,16 +197,74 @@ a:hover {
197197

198198
}
199199
/* Responsive Design */
200+
201+
.menu-toggle {
202+
display: none; /* Hidden by default */
203+
font-size: 1.5rem;
204+
background: none;
205+
border: none;
206+
color: white;
207+
cursor: pointer;
208+
}
209+
200210
@media (max-width: 768px) {
201-
nav ul {
202-
flex-direction: column;
211+
.nav-links {
212+
display: none; /* Hide links by default on mobile */
213+
flex-direction: column;
214+
position: absolute;
215+
top: 100px;
216+
left: 0px;
217+
background-color: #333;
218+
padding: 1rem;
219+
width: 150px;
220+
border-radius: 5px;
221+
background-color: #0a0316;
203222
}
204-
205-
nav ul li {
223+
.nav-links.show {
224+
display: flex; /* Show menu when toggled */
225+
}
226+
.nav-links li {
206227
margin: 0.5rem 0;
207228
}
208-
229+
.menu-toggle {
230+
display: block; /* Show the toggle button on mobile */
231+
}
232+
header {
233+
width: 100%;
234+
background-color: #0a0316;
235+
color: #fff;
236+
text-align: center;
237+
justify-content: space-between;
238+
align-items: center;
239+
transition: padding 0.8s ease, font-size 0.8s ease;
240+
z-index: 56;
241+
padding: 10px 10px;
242+
}
243+
header h1 {
244+
font-size: 18px;
245+
}
246+
header h3 {
247+
font-size: 0px;
248+
}
249+
header .header-image{
250+
width: 50px; /* Set a fixed width for the image */
251+
height: auto; /* Maintain aspect ratio */
252+
margin-right: 10px; /* Space between image and heading */
253+
padding: 0.3rem 0;
254+
}
209255
main {
210256
padding: 1rem;
211257
}
258+
.header-small {
259+
width: 100%;
260+
background-color: #0a0316;
261+
color: #fff;
262+
text-align: center;
263+
justify-content: space-between;
264+
align-items: center;
265+
transition: padding 0.8s ease, font-size 0.8s ease;
266+
z-index: 56;
267+
padding: 10px 10px;
268+
269+
}
212270
}

0 commit comments

Comments
 (0)