Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css: How to get screen height in css?

Tags:

css

.visitcard-ipcashier {
    position: fixed;
    background: white;
    top: 0;
    right: 0;
    height: 95%;
    overflow: auto;
    z-index: 50;
}

In the above code, i use height atrribute in 93%. But this varies depends on screen. How can i get screen height in css?

like image 813
Raghul Avatar asked Jul 24 '18 05:07

Raghul


People also ask

How do you measure screen height?

To evaluate the screen's length, height, and area, we can follow the same equations as for a flat one: height = diagonal / √(AR²+1) ; length = AR * height ; and. area = height * length .

How do you find the height of a viewport?

You can use the window. innerHeight property to get the viewport height, and the window. innerWidth to get its width. let viewportHeight = window.


1 Answers

You can't "get" the viewport height as such, in the way that you can with JS to store it in a variable, but you can use it in calc() to change the height of elements. For example, height: calc( 100vh - 50px ); which would equate to "the window height less 50px".

like image 182
Peter HvD Avatar answered Oct 23 '22 04:10

Peter HvD