Fixed navbar on mobile

This commit is contained in:
Firq 2023-03-04 20:11:51 +01:00
parent 8d2ef10fb7
commit fcf328b377
Signed by: Firq
GPG key ID: 3ACC61C8CEC83C20

View file

@ -5,16 +5,23 @@
<a href="/" rel="noopener noreferrer" aria-label="Home"> <a href="/" rel="noopener noreferrer" aria-label="Home">
<img src="link_192.png" alt=""> <img src="link_192.png" alt="">
</a> </a>
<ul class="desktop">
<slot />
</ul>
<button class="mobile">
<ul> <ul>
<slot /> <slot />
</ul> </ul>
<div class="placeholder"></div>
<i class="iconoir-menu"></i>
</button>
</header> </header>
<style> <style>
header { header {
background-color: #1e1e1e; background-color: #1e1e1e;
display: flex; display: flex;
height: 64px; height: auto;
width: 100%; width: 100%;
align-items: center; align-items: center;
line-height: 1.5em; line-height: 1.5em;
@ -30,10 +37,10 @@
width: 100%; width: 100%;
object-fit: contain; object-fit: contain;
} }
ul { .desktop {
align-items: center; align-items: center;
justify-content: space-around; justify-content: space-around;
display: flex; display: none;
flex-wrap: wrap; flex-wrap: wrap;
flex-direction: row; flex-direction: row;
height: 64px; height: 64px;
@ -45,4 +52,65 @@
margin-block-end: 0px; margin-block-end: 0px;
line-height: 1.5em; line-height: 1.5em;
} }
.mobile > ul {
background-color: #1e1e1e;
align-items: center;
flex-wrap: wrap;
flex-direction: column;
display: flex;
width: 100%;
list-style-type: none;
line-height: 3em;
}
.placeholder {
display: flex;
width: 100%;
}
.mobile {
display:flex;
background-color: #1e1e1e;
border: 0px;
width: 100%;
height: 64px;
}
.mobile > i {
color: white;
font-weight: bold;
font-size: 2em;
align-self: center;
padding-right: 1em;
}
.mobile > ul {
display: none;
padding: 0px;
}
.mobile:focus-within > ul{
display: flex;
}
.mobile:focus-within > .placeholder{
display: none;
}
.mobile:focus-within {
height: 256px;
}
@media (min-width: 1120px) {
.mobile {
display:none;
}
.desktop {
display: flex;
}
header {
height: 64px;
}
}
</style> </style>