Added js for navbar scroll
This commit is contained in:
parent
5fe32ff2c2
commit
34fd5607db
@ -14,7 +14,6 @@ html {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nav {
|
nav {
|
||||||
/*background: rgb(31, 33, 35);*/
|
|
||||||
height: auto;
|
height: auto;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@ -23,12 +22,11 @@ nav {
|
|||||||
position: fixed;
|
position: fixed;
|
||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
/*box-shadow: 0 1px 6px 0 rgb(0 0 0 / 20%);*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nav * {
|
nav * {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 1px 1px;
|
margin: 2px 5px;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
@ -110,7 +108,7 @@ nav li a:focus::after{
|
|||||||
font-size: 17px;
|
font-size: 17px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-background {
|
#header-background {
|
||||||
background-image: none;
|
background-image: none;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
@ -118,3 +116,71 @@ nav li a:focus::after{
|
|||||||
background-attachment: fixed;
|
background-attachment: fixed;
|
||||||
height: 100vh; /* makes it so it covers the entire page */
|
height: 100vh; /* makes it so it covers the entire page */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#header {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column nowrap;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
text-align: center;
|
||||||
|
position: relative;
|
||||||
|
background-image: linear-gradient(#0d111733 50%, #0d11175e 60%, #0d1117 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
#header-subtitle-date {
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#header-subtitle-spots {
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#entrance-arrow {
|
||||||
|
max-height: 90px;
|
||||||
|
max-width: 35px;
|
||||||
|
height: 50px;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
float: bottom;
|
||||||
|
animation: bounce 3s infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes bounce {
|
||||||
|
0%, 20%, 50%, 80%, 100% {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
40% {
|
||||||
|
transform: translateY(-5px);
|
||||||
|
}
|
||||||
|
60% {
|
||||||
|
transform: translateY(-3px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px 0 10px 0;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
text-align: center;
|
||||||
|
position: relative;
|
||||||
|
margin: auto;
|
||||||
|
display: grid;
|
||||||
|
padding-bottom: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
width: auto;
|
||||||
|
padding: 70px 0px 0 0px;
|
||||||
|
text-align: center;
|
||||||
|
align-items: center;
|
||||||
|
max-width: 1500px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.line {
|
||||||
|
width: 200px;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
5
css/scroll_nav.css
Normal file
5
css/scroll_nav.css
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
.pa-fixed-header {
|
||||||
|
background-color: rgb(24, 24, 24) !important;
|
||||||
|
box-shadow: 0 1px 6px 0 rgb(0 0 0 / 20%);
|
||||||
|
transition: background-color 0.25s ease-out;
|
||||||
|
}
|
BIN
img/Gilroy Hacks Logo [Summer-wide].png
Normal file
BIN
img/Gilroy Hacks Logo [Summer-wide].png
Normal file
Binary file not shown.
After Width: | Height: | Size: 320 KiB |
BIN
img/Gilroy Hacks Logo [Summer].png
Normal file
BIN
img/Gilroy Hacks Logo [Summer].png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
40
index.html
40
index.html
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
<title>Gilroy Hacks</title>
|
<title>Gilroy Hacks</title>
|
||||||
<link href="css/general.css" rel="stylesheet" type="text/css" media="all">
|
<link href="css/general.css" rel="stylesheet" type="text/css" media="all">
|
||||||
|
<link href="css/scroll_nav.css" rel="stylesheet" type="text/css" media="all">
|
||||||
<link rel="icon" href="">
|
<link rel="icon" href="">
|
||||||
<meta name="author" content="Gilroy Hacks">
|
<meta name="author" content="Gilroy Hacks">
|
||||||
<meta name="copyright" content="This site and its pages are Copyright (c) 2022 Gilroy Hacks All Rights Reserved.">
|
<meta name="copyright" content="This site and its pages are Copyright (c) 2022 Gilroy Hacks All Rights Reserved.">
|
||||||
@ -34,29 +35,48 @@
|
|||||||
</style>
|
</style>
|
||||||
<!--For icons, go here: https://iconsvg.xyz/ -->
|
<!--For icons, go here: https://iconsvg.xyz/ -->
|
||||||
</head>
|
</head>
|
||||||
<header>
|
<body></body>
|
||||||
<div class="header-background">
|
<!--Nav-->
|
||||||
<div id="header">
|
<nav id="navBar">
|
||||||
<nav>
|
|
||||||
<a href="./">
|
<a href="./">
|
||||||
<img id="logo" src="img/Gilroy Hacks Logo [wide transparent].png" loading="lazy" height="55" width="auto" alt="logo"/>
|
<img src="img/Gilroy Hacks Logo [Summer-wide].png" loading="lazy" height="55" width="auto" alt="logo"/>
|
||||||
</a>
|
</a>
|
||||||
<input type="checkbox" id="check">
|
<input type="checkbox" id="check">
|
||||||
<label for="check" class="checkbtn">
|
<label for="check" class="checkbtn">
|
||||||
<img src="img/bars.png" loading="lazy" height="20" width="25" alt="Bars"/>
|
<img src="img/bars.png" loading="lazy" height="20" width="25" alt="Bars"/>
|
||||||
</label>
|
</label>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="">Event</a></li>
|
<li><a href="event">Event</a></li>
|
||||||
<li><a href="">Rules</a></li>
|
<li><a href="rules">Rules</a></li>
|
||||||
<li><a href="">Prizes</a></li>
|
<li><a href="prizes">Prizes</a></li>
|
||||||
<li><a href="">Teams</a></li>
|
<li><a href="teams">Teams</a></li>
|
||||||
<a href=""></a><li id="sign-up">SIGN UP</li></a>
|
<a href=""></a><li id="sign-up">SIGN UP</li></a>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
<!--Front Page-->
|
||||||
|
<header>
|
||||||
|
<div id="header-background">
|
||||||
|
<div id="header">
|
||||||
|
<img id="logo" src="img/Gilroy Hacks Logo [Summer].png" height="300" width="300" loading="lazy" alt="logo"/>
|
||||||
|
<hr class="line">
|
||||||
|
<h2 id="header-subtitle-date">Aug 12 - 14</h2>
|
||||||
|
<h2 id="header-subtitle-spots">40 spots Left</h2>
|
||||||
|
<div id="entrance-arrow">
|
||||||
|
<a href="#event" class="link">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<body>
|
<!--Main-->
|
||||||
|
<main>
|
||||||
|
<section id="event">Event</section>
|
||||||
|
<section id="rules">Rules</section>
|
||||||
|
<section id="prizes">Prizes</section>
|
||||||
|
<section id="teams">Teams</section>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<script src="js/scroll_nav.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
30
js/scroll_nav.js
Normal file
30
js/scroll_nav.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
// Toggle the .pa-fixed-header class when the user
|
||||||
|
// scroll 100px
|
||||||
|
|
||||||
|
window.onscroll = () => {scrollNavbar()};
|
||||||
|
|
||||||
|
scrollNavbar = () => {
|
||||||
|
// Target elements
|
||||||
|
const navBar = document.getElementById("navBar");
|
||||||
|
const links = document.querySelectorAll("#navBar a");
|
||||||
|
|
||||||
|
if (document.documentElement.scrollTop > 100) {
|
||||||
|
navBar.classList.add("pa-fixed-header");
|
||||||
|
|
||||||
|
// Change the color of links on scroll
|
||||||
|
for (let i = 0; i < links.length; i++) {
|
||||||
|
const element = links[i];
|
||||||
|
element.classList.add('text-black');
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
navBar.classList.remove("pa-fixed-header");
|
||||||
|
|
||||||
|
// Change the color of links back to default
|
||||||
|
for (let i = 0; i < links.length; i++) {
|
||||||
|
const element = links[i];
|
||||||
|
element.classList.remove('text-black');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user