I'm new to JavaScript and currently working on implementing a sidebar navigation. I found a tutorial on W3Schools, but the script provided only works for full-screen desktop browsers.
<script>
function openNav() {
document.getElementById("mySidebar").style.width = "250px";
document.getElementById("main").style.marginLeft = "250px";
}
function closeNav() {
document.getElementById("mySidebar").style.width = "0";
document.getElementById("main").style.marginLeft= "0";
}
</script>
As you can see, it expands the width to 250px, but for mobile responsiveness, it should expand to 70-80px.
How can I make this work for different screen resolutions?