Skip to content

Instantly share code, notes, and snippets.

@curiositry
Created March 14, 2022 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save curiositry/02332a1b6d5da73ea85c14d623e6b29f to your computer and use it in GitHub Desktop.
Save curiositry/02332a1b6d5da73ea85c14d623e6b29f to your computer and use it in GitHub Desktop.
Weblog responsive navigation (paste into your code injection pane)
<style>
.menu-toggle {
display: block;
}
header nav.hidden {
display: none;
}
@media all and (min-width: 800px) {
header nav.hidden {
display: block;
}
.menu-toggle {
display: none;
}
}
</style>
<script>
window.onload = function(){
document.querySelector("header .main-header__text-container").insertAdjacentHTML( 'afterend', '<a class="menu-toggle" onclick="toggleMenu();" href="#!"><b>≡ MENU</b></a>' );
document.querySelector(".menu-toggle").hidden = false;
document.querySelector("header nav").classList.add("js");
toggleMenu = function(){
document.querySelector("header nav").classList.toggle("hidden");
}
toggleMenu()
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment