2024-04-14 08:52:52 +00:00
|
|
|
<nav class="navbar">
|
2024-04-11 15:57:02 +00:00
|
|
|
<ul class="nav__menu">
|
2024-04-14 08:52:52 +00:00
|
|
|
{% for page in collections.pages %}
|
|
|
|
<li><a href="{{ page.url }}">{{ page.data.title }}</a></li>
|
|
|
|
{%- endfor %}
|
2024-04-11 15:57:02 +00:00
|
|
|
<li><a href="https://leilukin.123guestbook.com/">Guestbook</a></li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
|
2024-04-14 08:52:52 +00:00
|
|
|
<style>
|
2024-04-12 03:05:05 +00:00
|
|
|
.navbar {
|
2024-04-11 15:57:02 +00:00
|
|
|
background: var(--clr-navbar-bg);
|
|
|
|
padding: 0 0.6rem;
|
|
|
|
width: 100%;
|
|
|
|
z-index: 999;
|
|
|
|
}
|
|
|
|
|
|
|
|
.navbar a {
|
|
|
|
color: var(--clr-navbar-link);
|
|
|
|
text-decoration: none;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
.navbar a:hover {
|
|
|
|
color: var(--clr-link-hover);
|
|
|
|
}
|
|
|
|
|
|
|
|
.navbar a:focus {
|
|
|
|
outline-offset: 0.3em;
|
|
|
|
outline: 0.15em solid var(--clr-navbar-link);
|
|
|
|
}
|
|
|
|
|
|
|
|
.nav__menu {
|
|
|
|
list-style: none;
|
|
|
|
padding: 0;
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-evenly;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
gap: 0.5rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Added to the navbar with JS when it reaches its scroll position */
|
|
|
|
.sticky-nav {
|
|
|
|
position: fixed;
|
|
|
|
width: 100%;
|
|
|
|
top: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add some top padding to the page content to prevent sudden quick movement
|
|
|
|
as the navigation bar gets a new position at the top of the page
|
|
|
|
(position:fixed and top:0) */
|
|
|
|
.sticky-nav + main {
|
|
|
|
padding-top: 2rem;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
2024-04-14 08:52:52 +00:00
|
|
|
<script defer>
|
2024-04-11 15:57:02 +00:00
|
|
|
// Make the navigation bar sticky
|
2024-04-11 16:32:09 +00:00
|
|
|
// const header = document.querySelector(".main-header");
|
2024-04-12 03:05:05 +00:00
|
|
|
const navbar = document.querySelector(".navbar");
|
2024-04-11 15:57:02 +00:00
|
|
|
window.addEventListener("scroll", e => {
|
|
|
|
const scrollPos = window.scrollY || document.documentElement.scrollTop;
|
2024-04-11 16:13:44 +00:00
|
|
|
const stickyLine = document.querySelector(".main-header").scrollHeight - navbar.scrollHeight;
|
2024-04-11 15:57:02 +00:00
|
|
|
if (scrollPos > stickyLine) {
|
|
|
|
navbar.classList.add("sticky-nav");
|
|
|
|
} else {
|
|
|
|
navbar.classList.remove("sticky-nav");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|