add responsive menu

This commit is contained in:
Wonderfall 2022-07-25 06:08:07 +02:00
parent 5737f8613c
commit 723ac4f5c6
2 changed files with 66 additions and 0 deletions

View File

@ -61,6 +61,69 @@ body:not(.dark) #sun {
margin-inline-start: var(--gap); margin-inline-start: var(--gap);
} }
#hamburger-menu {
display: none;
width: 18px;
height: 18px;
margin: auto;
margin-right: 3px;
margin-left: 3px;
background: linear-gradient(
var(--primary), var(--primary) 20%,
#ffffff00 20%, #ffffff00 40%,
var(--primary) 40%, var(--primary) 60%,
#ffffff00 60%, #ffffff00 80%,
var(--primary) 80%, var(--primary) 100%
);
z-index: 10001;
}
@media screen and (max-width: 900px) {
#menu {
display: none;
}
#hamburger-menu {
display: inline;
}
#hamburger-input:checked ~ .overlay {
visibility: visible;
}
#hamburger-input:checked ~ #menu {
display: block;
width: 80%;
margin: auto;
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
z-index: 10002;
}
#menu li {
text-align: center;
}
#menu li + li {
margin-inline-start: 0;
}
}
.overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
visibility: hidden;
overflow: hidden;
background: var(--theme);
z-index: 10000;
}
#menu a { #menu a {
font-size: 16px; font-size: 16px;
} }

View File

@ -89,6 +89,9 @@
</div> </div>
</div> </div>
{{- $currentPage := . }} {{- $currentPage := . }}
<input id="hamburger-input" type="checkbox"></input>
<label id="hamburger-menu" for="hamburger-input"></label>
<div class="overlay"></div>
<ul id="menu"> <ul id="menu">
{{- range site.Menus.main }} {{- range site.Menus.main }}
{{- $menu_item_url := (cond (strings.HasSuffix .URL "/") .URL (printf "%s/" .URL) ) | absLangURL }} {{- $menu_item_url := (cond (strings.HasSuffix .URL "/") .URL (printf "%s/" .URL) ) | absLangURL }}