I am currently working on creating a form where individuals can input their email addresses to receive some information. My goal is to design one HTML file that will work seamlessly on both desktop and mobile views by adjusting the form width based on the window size. While my script initially sets the appropriate form width upon loading the HTML document, it fails to resize when I adjust the window size. What mistake did I make in my code?
<div id="center" class="container-fluid" font-size=13px; onresize="resize()">
<script>
let out = "75%"
if (window.innerWidth > window.innerHeight){
out = "35%"
} else{
out = "80%"
}
document.getElementById("center").style.width = out;
document.getElementsByTagName("BODY")[0].onreize = function() {myFunction()};
function resize(){
out = "75%"
if (window.innerWidth > window.innerHeight){
out = "35%"
} else{
out = "80%"
}
document.getElementById("center").style.width = out;
}
</script>
</div>