Set dynamic height for div with javascript

1

I would like a script that takes my div with class master and set height: 100% according to the size of the screen.

html:

   <!DOCTYPE html>
    <html lang="pt-br">
    <head>
        <meta charset="UTF-8">
        <title>*</title>
        <link rel="stylesheet" href="style.css">
    </head>
    <body>
        <div class="master">
        <header>
        </header>
        <footer>        
        </footer>
        </div>
    </body>
    </html>

css:

*{}
html {

}

body {
  margin: 0;
}
.container{
    float: left;
    width: 100%;
    margin: 0 auto;
    padding:0 15px;
}
    
asked by anonymous 28.02.2018 / 19:07

1 answer

0

Look, I do not think it's necessary to use js for this. I have had problems with this before ... The case is that the height 100% is referring to the parent element, which in this case has no height defined and 100% of nothing is nothing!

Do this in css:

html, body{
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

.master{height:100%;}

See if it works ...

    
28.02.2018 / 19:11