Skip to content

Commit abd4840

Browse files
committed
responsive menu update
1 parent e6433d7 commit abd4840

3 files changed

Lines changed: 69 additions & 12 deletions

File tree

index.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
<a href="#headerSection">
1717
<img class="profileImage" src="./profileImage.png" />
1818
</a>
19-
<a class="navbarLink" href="#section1">Über Mich</a>
20-
<a class="navbarLink" href="#section2">Links</a>
21-
<a class="navbarLink" href="#section3">Projekte</a>
22-
<a class="navbarLink" href="#section4"></a>
19+
<div class="linkContainer" id="linkContainer">
20+
<a class="navbarLink" href="#section1">Über Mich</a>
21+
<a class="navbarLink" href="#section2">Links</a>
22+
<a class="navbarLink" href="#section3">Projekte</a>
23+
</div>
24+
<button class="navbarButton" onclick="navbarToggle()">Menu</button>
2325
</nav>
2426
<div class="banner">
2527
<h1>ERPI CODING</h1>

script.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const arrowToTop = document.getElementById("arrowToTop");
22
const navbar = document.querySelector(".navbar");
3+
const linkContainer = document.getElementById("linkContainer");
34

45
window.addEventListener("scroll", function () {
56
const scrollHeight = window.pageYOffset;
@@ -12,8 +13,12 @@ window.addEventListener("scroll", function () {
1213
}
1314
});
1415

15-
selectLanguage(3);
16+
function navbarToggle() {
17+
linkContainer.classList.toggle("showLinks");
18+
navbar.classList.toggle("showLinks");
19+
}
1620

21+
selectLanguage(3);
1722
function selectLanguage(languageId) {
1823
for (let i = 1; i <= 4; i++) {
1924
document.getElementById("select" + i).style.flexGrow = "1";

style.css

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ header {
3030

3131
position: absolute;
3232
display: flex;
33-
align-items: center;
3433

3534
border-radius: 30px;
35+
36+
transition: 500ms;
3637
}
3738
.navbarFixed {
3839
position: fixed;
40+
display: flex;
41+
3942
top: 0px;
4043
left: 0px;
4144
z-index: 10;
@@ -44,33 +47,69 @@ header {
4447
box-shadow: 0 0 5px var(--petrol-transparent);
4548

4649
backdrop-filter: blur(5px);
50+
51+
transition: 500ms;
4752
}
4853
.profileImage {
4954
height: 40px;
5055
width: 40px;
51-
margin: 10px;
56+
margin: 7.5px 10px 7.5px 10px;
5257

53-
border: white solid 2px;
54-
border-radius: 22px;
58+
border: white solid 2.5px;
59+
border-radius: 21.25px;
5560
}
56-
.navbarLink {
61+
.navbarButton {
5762
height: 60px;
58-
margin: 20px;
63+
margin: 0 20px 0 20px;
64+
margin-right: 0px;
5965

6066
align-content: center;
6167

6268
text-decoration: none;
6369
font-weight: 600;
6470
font-size: 24px;
71+
72+
background-color: hsla(0, 0%, 0%, 0);
73+
border: none;
74+
visibility: hidden;
6575
}
6676
.navbarLink {
77+
height: 60px;
78+
margin: 0 20px 0 20px;
79+
80+
align-content: center;
81+
z-index: 16;
82+
83+
text-decoration: none;
84+
font-weight: 600;
85+
font-size: 24px;
86+
6787
transition: 500ms;
6888
}
6989
.navbarLink:hover {
7090
transition: all 500ms;
7191
/*color: var(--grey-light);*/
7292
font-weight: 800;
7393
}
94+
@media (max-width: 600px) {
95+
.linkContainer {
96+
width: calc(100% - 180px);
97+
98+
display: flex;
99+
flex-direction: column;
100+
overflow: hidden;
101+
height: 0px;
102+
103+
transition: 500ms;
104+
}
105+
.navbarButton {
106+
visibility: visible;
107+
}
108+
}
109+
.showLinks {
110+
height: 180px;
111+
transition: 500ms;
112+
}
74113
.banner {
75114
display: flex;
76115
flex-direction: column;
@@ -100,6 +139,7 @@ header {
100139
margin: 0px;
101140
padding: 5px;
102141

142+
align-content: center;
103143
font-weight: bold;
104144
text-decoration: none;
105145
border: white solid 2px;
@@ -139,6 +179,7 @@ h6 {
139179
border-radius: 25px;
140180

141181
font-size: larger;
182+
overflow: hidden;
142183
}
143184

144185
div.languageSelector {
@@ -152,6 +193,7 @@ div.languageSelector {
152193
button.language {
153194
width: auto;
154195
height: 50px;
196+
min-width: 50px;
155197
flex-grow: 1;
156198

157199
background-color: var(--petrol-transparent);
@@ -177,11 +219,19 @@ button.language:hover {
177219

178220
float: left;
179221
}
222+
@media (max-width: 400px) {
223+
#languageText {
224+
clear: left !important;
225+
}
226+
}
227+
180228
#languageLogoSource {
181229
clear: left;
182230
font-size: 12px;
231+
text-wrap: wrap;
183232
}
184-
233+
/* Linktree sction
234+
*/
185235
.linksBg {
186236
display: flex;
187237
flex-direction: column;

0 commit comments

Comments
 (0)