CSS get height of screen resolution
You could use viewport-percentage lenghts.
See: http://stanhub.com/how-to-make-div-element-100-height-of-browser-window-using-css-only/
It works like this:
.element{
height: 100vh; /* For 100% screen height */
width: 100vw; /* For 100% screen width */
}
More info also available through Mozilla Developer Network and W3C.
Adding to @Hendrik Eichler Answer, the n vh
uses n%
of the viewport's initial containing block.
.element{
height: 50vh; /* Would mean 50% of Viewport height */
width: 75vw; /* Would mean 75% of Viewport width*/
}
Also, the viewport height is for devices of any resolution, the view port height, width is one of the best ways (similar to css design using % values but basing it on the device's view port height and width)
vh
Equal to 1% of the height of the viewport's initial containing block.
vw
Equal to 1% of the width of the viewport's initial containing block.
vi
Equal to 1% of the size of the initial containing block, in the direction of the root element’s inline axis.
vb
Equal to 1% of the size of the initial containing block, in the direction of the root element’s block axis.
vmin
Equal to the smaller of vw and vh.
vmax
Equal to the larger of vw and vh.
Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/length#Viewport-percentage_lengths