Skip to content

Commit 14e4052

Browse files
committed
Mobile Navigation
1 parent 4a08160 commit 14e4052

File tree

4 files changed

+77
-1
lines changed

4 files changed

+77
-1
lines changed

starter/08-Omnifood-Responsive/css/general.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,15 @@ html {
6767
/* 10px / 16px = 0.625 = 62.5% */
6868
/* Percentage of user's browser font-size setting */
6969
font-size: 62.5%;
70+
overflow-x: hidden;
7071
}
7172

7273
body {
7374
font-family: "Rubik", sans-serif;
7475
line-height: 1;
7576
font-weight: 400;
7677
color: #555;
78+
overflow-x: hidden;
7779
}
7880

7981
/**************************/

starter/08-Omnifood-Responsive/css/queries.css

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,55 @@
120120
.btn--form {
121121
margin-top: 1.2rem;
122122
}
123+
124+
/* Mobile Navigation */
125+
.btn-mobile-nav {
126+
display: block;
127+
}
128+
129+
.main-nav {
130+
background-color: rgba(255, 255, 255, 0.97);
131+
position: absolute;
132+
top: 0;
133+
left: 0;
134+
width: 100%;
135+
height: 100vh;
136+
transform: translateX(100%);
137+
138+
display: flex;
139+
align-items: center;
140+
justify-content: center;
141+
transition: all 0.5s ease-in;
142+
/* 1. Hide it visually */
143+
opacity: 0;
144+
/* 2. Make it unaccessible to mouse and keyboard */
145+
pointer-events: none;
146+
/* 3. Hide it from screen readers */
147+
visibility: hidden;
148+
}
149+
150+
.nav-open .main-nav {
151+
opacity: 1;
152+
pointer-events: auto;
153+
visibility: visible;
154+
transform: translateX(0);
155+
}
156+
157+
.nav-open .icon-mobile-nav[name="close-outline"] {
158+
display: block;
159+
}
160+
161+
.nav-open .icon-mobile-nav[name="menu-outline"] {
162+
display: none;
163+
}
164+
165+
.main-nav-list {
166+
flex-direction: column;
167+
gap: 4.8rem;
168+
}
169+
170+
.main-nav-link:link,
171+
.main-nav-link:visited {
172+
font-size: 3rem;
173+
}
123174
}

starter/08-Omnifood-Responsive/css/style.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/* Because we want header to be sticky later */
1212
height: 9.6rem;
1313
padding: 0 4.8rem;
14+
position: relative;
1415
}
1516

1617
.logo {
@@ -56,6 +57,24 @@
5657
background-color: #cf711f;
5758
}
5859

60+
/* Mobile */
61+
.btn-mobile-nav {
62+
border: none;
63+
background: none;
64+
cursor: pointer;
65+
display: none;
66+
}
67+
68+
.icon-mobile-nav {
69+
height: 4.8rem;
70+
width: 4.8rem;
71+
color: #333;
72+
}
73+
74+
.icon-mobile-nav[name="close-outline"] {
75+
display: none;
76+
}
77+
5978
/**************************/
6079
/* HERO SECTION */
6180
/**************************/

starter/08-Omnifood-Responsive/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<title>Omnifood</title>
2828
</head>
2929
<body>
30-
<header class="header">
30+
<header class="header nav-open">
3131
<a href="#">
3232
<img class="logo" alt="Omnifood logo" src="img/omnifood-logo.png" />
3333
</a>
@@ -40,6 +40,10 @@
4040
<li><a class="main-nav-link nav-cta" href="#">Try for free</a></li>
4141
</ul>
4242
</nav>
43+
<button class="btn-mobile-nav">
44+
<ion-icon class="icon-mobile-nav" name="menu-outline"></ion-icon>
45+
<ion-icon class="icon-mobile-nav" name="close-outline"></ion-icon>
46+
</button>
4347
</header>
4448

4549
<main>

0 commit comments

Comments
 (0)