2020-12-31

How do I resize my inputs depending on the screen size (chosen by the user in the popup)

const sheets = document.getElementById('sheets');

const siteDocument = document.getElementsByTagName('body')[0];

const amountOfColumns = 2;

const amountOfRows = undefined;

for (var i = 0; i < amountOfColumns; i++) {
  const myNewElement = document.createElement('input');
  myNewElement.width = siteDocument
  sheets.appendChild(myNewElement)
}
for (var x = 0; x < amountOfRows; x++) {

}
#titletext {
  font-size: 5vh;
}
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>repl.it</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
    <div id="popup"></div>
    <h1 id="titletext">Excel Sheets</h1>
    <div id="buttons"></div>
    <div id="sheets"></div>
    <script src="script.js"></script>
  </body>
</html>

My questions:

  1. How do I get it so the width the element created depends on the width of the screen your using (the user chooses amount of inputs rows and columns), I want to make it responsive and in case there is a bunch of inputs I want to make it so it fits on the screen without having to use the scroll bar (because it's a big pain and I want to code something actually good...)

  2. (You don't have to answer this question) Is vh (view-height) good for responsive web design?

UPDATE:

I want an equation that let's me have ALL the columns and rows on the screen, if I had say 10 columns it should all be on the screen (NOTE: The reason an equation is needed is because I want the columns and rows to be choosen by the user(Is this a bad approach? I'm not sure how I would do it without that)



from Recent Questions - Stack Overflow https://ift.tt/3pzKlro
https://ift.tt/eA8V8J

No comments:

Post a Comment