I try to hide/show a vertical nav. Both when resizing and by a hamburger icon. The odd is that each routine works as expected when used one by one. But once triggered the Javascript, the @media stops working.
The Javascript:
<script>
function toggle() {
var n = document.getElementById("nav");
var c = document.getElementById("content");
if (n.style.display === "none") {
n.style.display = "block ";
c.style.gridColumn = "2/3";
} else {
n.style.display = "none";
c.style.gridColumn = "1/3"
}
}
</script>
and the css @media:
@media only screen and (max-width: 880px) {
.grid {
grid-template-columns: max-content;
}
.nav {
display: none;
}
}
function toggle() {
var n = document.getElementByClassName("nav");
if (n.style.width === "0px") {
n.classList.remove("nav");
} else {
n.classList.add("nav");
}
}