Basically, what I am trying to do is create a form for people to enter their emails into to get sent some info. I want to create one html file for both desktop and mobile views such that the width of form takes up 75% of the screen when the window is narrow and 35% when the window is wide. My script right now creates the correct size window when the html document is first loaded, but when I resize the window it doesn't resize it. What did I do wrong with my code?
<div id="center" class="container-fluid" font-size=13px; onresize="resize()">
<script>
out = "75%"
if (window.innerWidth > window.innerHeight){
out = "35%"
} else{
out = "80%"
}
document.getElementById("center").style.width = out;
document.getElementsByTagName("BODY")[0].onresize = function() {myFunction()};
function resize(){
out = "75%"
if (window.innerWidth > window.innerHeight){
out = "35%"
} else{
out = "80%"
}
document.getElementById("center").style.width = out;
}
</script>
</div>