Subject. How to do on js in the know. I wonder if there is a solution on css. I can’t think of it myself.

In general, the task is as follows. There is a long page, inside there is a block on top. This block should be the height of the page, because there is a form in it that must be centered.

  • I'm really not a typewriter, but I heard something like the edge of my ear. In percent like nothing, only in pixels. - dlarchikov

3 answers 3

Did I understand you correctly? Example

body { width: 5000px; height: 5000px; background: red; } .container { background: yellow; opacity: .5; position: absolute; left: 0; right: 0; bottom: 0; top:0; } 
 <div class="container"></div> 

  • How trite. - ReklatsMasters
  • @ReklatsMasters Is it really bad? solution is a solution - Vasily Barbashev

It is better to use vh :

 .my_div { height:100vh; } 
  • In iOS 7, there is support for vh, but it is a curve. In general, vh has a huge amount of restrictions. I use only for home projects. - ReklatsMasters September

set the height of html and body 100%, then set the height of 100% to the necessary (child) block and it will stretch to the full height of the screen.