Add fallback for older browsers that do not support HTML popover

This commit is contained in:
Helen Chong 2024-07-24 20:10:18 +08:00
parent e051095ce3
commit e76ac1778b
1 changed files with 22 additions and 9 deletions

View File

@ -52,7 +52,14 @@
.navbar__menu a:hover { color: var(--clr-link-hover); }
.navbar__menu a:focus { outline-offset: 0.2em; }
.navbar__links { display: none; }
.navbar__links {
display: none;
flex-wrap: wrap;
justify-content: space-evenly;
gap: 0.5em;
}
.navbar__toggle {
background-color: inherit;
@ -89,12 +96,18 @@
@media only screen and (min-width: 43.75rem) {
.navbar { padding: 1em 0.6em; }
.navbar__toggle, .navbar__popover { display: none; }
.navbar__links {
display: flex;
flex-wrap: wrap;
justify-content: space-evenly;
gap: 0.5em;
}
.navbar__links { display: flex; }
}
{% endcss %}
{% endcss %}
{%- js %}
function supportsPopover() {
return HTMLElement.prototype.hasOwnProperty("popover");
}
const popoverSupported = supportsPopover();
if (!popoverSupported) {
document.querySelector(".navbar__toggle").style.display = "none";
document.querySelector(".navbar__links").style.display = "flex";
}
{% endjs %}