milad
milad

Reputation: 79

how to get width of screen and add some value to it in css

I want to get the screen size and add 253px to it
Or something like this in css

width: (100% + 253px)

how can I make this happen?

Upvotes: 2

Views: 960

Answers (3)

Zeinab
Zeinab

Reputation: 76

For the CSS to measure a percent of the window screen and add to or cut from that amount in a pixel scale, you'll need to hit ElementSelector { width: calc(100% - 253px) } in your CSS (without "calc" function, that math calculation can't be computed since they're of different scales).

Upvotes: 0

Aalexander
Aalexander

Reputation: 5004

You can set width and height relative to the viewport. with vh, vw

There you can add an offset in px with the following line of code.

.container { min-height: calc("~100vh - 150px"); } 

Upvotes: 1

milad
milad

Reputation: 79

tnx to my freind Alenx

.container { min-height: calc("~100vh - 150px"); } 

Upvotes: 1

Related Questions