0

How Can I create a 100% height div of the current viewport size?

I know there are many resolutions around there, and I want to create a div that is high enough to cover the current size of the viewport.

Suppose the viewport is at the moment the size of one of a 1920x1080 resolution screen, but Also, someone else from a 1024x768 resolution screen wants to view the page, I want the div to be displayed 100% of the height of the viewport it is displayed on.

Is it possible with just css?

CodeTrooper
  • 1,890
  • 6
  • 32
  • 54

2 Answers2

1

give 100% height to html and body, as well as to the div.

-1

You can use a fixed position. Add this to the body:

<div style="position:fixed; width:100%; height:100%; top:0; left:0;"></div>
DreamWave
  • 1,934
  • 3
  • 28
  • 59