Fix navbar on very small screens
This commit is contained in:
parent
42945b97c0
commit
69e5b93d2e
3 changed files with 19 additions and 8 deletions
|
@ -1,6 +1,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="./index.scss" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
</head>
|
||||
<body>
|
||||
<header class="header">
|
||||
|
@ -28,6 +29,6 @@
|
|||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
<script src="index.js"></script>
|
||||
<script src="index.js" type="module"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
window.addEventListener("load", function() {
|
||||
window.addEventListener("load", function () {
|
||||
const NAVBAR_BUTTON = document.querySelector("button.side-menu");
|
||||
|
||||
// HACK: Work around window resizing whilst the modal is open animating its size,
|
||||
// by closing the modal whenever the window is resized
|
||||
window.addEventListener("resize", function() {
|
||||
window.addEventListener("resize", function () {
|
||||
NAVBAR_BUTTON.blur();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -18,7 +18,8 @@ header {
|
|||
padding: 0;
|
||||
}
|
||||
|
||||
.menu, .icons {
|
||||
.menu,
|
||||
.icons {
|
||||
list-style: none;
|
||||
display: inline-flex;
|
||||
margin: 0;
|
||||
|
@ -51,12 +52,13 @@ header {
|
|||
height: 100vh;
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
transition-duration: 0.25s;
|
||||
transition-duration: 0.2s;
|
||||
transition-timing-function: ease-in-out;
|
||||
overflow: hidden;
|
||||
overflow: scroll;
|
||||
flex-direction: column;
|
||||
|
||||
.menu, .icons {
|
||||
.menu,
|
||||
.icons {
|
||||
display: initial;
|
||||
text-align: center;
|
||||
|
||||
|
@ -81,7 +83,7 @@ header {
|
|||
}
|
||||
|
||||
.nav-close {
|
||||
position: absolute;
|
||||
position: fixed;
|
||||
top: 1rem;
|
||||
right: 1rem;
|
||||
color: white;
|
||||
|
@ -108,3 +110,11 @@ header {
|
|||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-height: 500px) {
|
||||
/* If the window is small enough, items are pushed out the viewport, as it's positioned
|
||||
in the middle of the screen. This fixes it to the top so it can scroll properly. */
|
||||
nav {
|
||||
justify-content: unset;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue