Skip to content

Commit 24f4b8b

Browse files
committed
Complete project
1 parent 03ee803 commit 24f4b8b

File tree

5 files changed

+118
-257
lines changed

5 files changed

+118
-257
lines changed

24 - Sticky Nav/index-FINISHED.html

-67
This file was deleted.

24 - Sticky Nav/index-START.html 24 - Sticky Nav/index.html

+15-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>Sticky Nav</title>
6-
<link rel="stylesheet" href="style-START.css">
6+
<link rel="stylesheet" href="style.css">
77
</head>
88
<body>
99

@@ -54,6 +54,20 @@ <h1>A story about getting lost.</h1>
5454
</div>
5555

5656
<script>
57+
const nav = document.querySelector("#main");
58+
const navTop = nav.offsetTop;
59+
60+
function fixNav() {
61+
if (window.scrollY >= navTop ) {
62+
document.body.style.paddingTop = nav.offsetHeight + "px";
63+
document.body.classList.add("fixed-nav")
64+
} else {
65+
document.body.style.paddingTop = 0;
66+
document.body.classList.remove("fixed-nav")
67+
}
68+
}
69+
70+
window.addEventListener("scroll", fixNav)
5771

5872
</script>
5973

24 - Sticky Nav/style-FINISHED.css

-101
This file was deleted.

24 - Sticky Nav/style-START.css

-88
This file was deleted.

24 - Sticky Nav/style.css

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
html {
2+
box-sizing: border-box;
3+
background: #eeeeee;
4+
font-family: 'helvetica neue';
5+
font-size: 20px;
6+
font-weight: 200;
7+
}
8+
9+
body {
10+
margin: 0;
11+
}
12+
13+
*,
14+
*:before,
15+
*:after {
16+
box-sizing: inherit;
17+
}
18+
19+
.site-wrap {
20+
max-width: 700px;
21+
margin: 70px auto;
22+
background: white;
23+
padding: 40px;
24+
text-align: justify;
25+
box-shadow: 0 0 10px 5px rgba(0, 0, 0, 0.05);
26+
transform: scale(0.98);
27+
transition: transform 0.5s;
28+
}
29+
30+
.fixed-nav .site-wrap {
31+
transform: scale(1);
32+
}
33+
34+
header {
35+
text-align: center;
36+
height: 50vh;
37+
background: url(http://wes.io/iEgP/wow-so-deep.jpg) bottom center no-repeat;
38+
background-size: cover;
39+
display: flex;
40+
align-items: center;
41+
justify-content: center;
42+
}
43+
44+
h1 {
45+
color: white;
46+
font-size: 7vw;
47+
text-shadow: 3px 4px 0 rgba(0, 0, 0, 0.2);
48+
}
49+
50+
nav {
51+
background: black;
52+
top: 0;
53+
width: 100%;
54+
transition: all 0.5s;
55+
position: relative;
56+
z-index: 1;
57+
}
58+
59+
.fixed-nav nav {
60+
position: fixed;
61+
box-shadow: 0, 5px rgb(0, 0, 0, 0.1);
62+
}
63+
64+
nav ul {
65+
margin: 0;
66+
padding: 0;
67+
list-style: none;
68+
display: flex;
69+
}
70+
71+
nav li {
72+
flex: 1;
73+
text-align: center;
74+
display: flex;
75+
justify-content: center;
76+
align-items: center;
77+
}
78+
79+
li.logo {
80+
max-width: 0;
81+
overflow: hidden;
82+
background: white;
83+
transition: all .5s;
84+
font-weight: 600;
85+
font-size: 30px;
86+
}
87+
88+
.fixed-nav li.logo {
89+
max-width: 500px;
90+
}
91+
92+
li.logo a {
93+
color: black;
94+
}
95+
96+
nav a {
97+
text-decoration: none;
98+
padding: 20px;
99+
display: inline-block;
100+
color: white;
101+
transition: all 0.2s;
102+
text-transform: uppercase;
103+
}

0 commit comments

Comments
 (0)