7

.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?

Raghul
  • 213
  • 1
  • 5
  • 9

4 Answers4

31

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".

Peter HvD
  • 1,623
  • 1
  • 7
  • 14
6

In this case I suggest you to use vh (hundreds of viewport height): If you set height: 100vh; it would take 100% height of each screen.

Code Example

besartm
  • 558
  • 1
  • 7
  • 14
1

You need to use javascript to get screen's information.

Shahriat Hossain
  • 340
  • 4
  • 12
1

It is not possible using CSS, however you can control the page design using media queries.

Or, you can get the screen height by using screen.height and width by using screen.width. [They are JS properties]

Here is a basic JS code of doing this:

console.log("Width: "+screen.width+": Height: "+screen.height);
Code_Ninja
  • 1,729
  • 1
  • 14
  • 38