52

Is there a was of using screen.width inside calc? Something like this:

 left: calc(250px + screen.width - 1024px)!important;

It is for a concrete situation where the @media(max-width: 1024px) won't work.

Sefean
  • 591
  • 1
  • 7
  • 20

3 Answers3

87

100vw = 100% of viewport width

left:calc(250px + 100vw - 1024px)!important;
Ehsan
  • 12,655
  • 3
  • 25
  • 44
7

You can use vw units to size things in relation to viewport width, so try this:

left: calc(250px + 100vw - 1024px) !important;
jberglund
  • 174
  • 3
2

left: calc(250px + 100vw - 1024px)!important; this probably won't work I would do it like this: calc(100vw - 774px); (1024 - 250 = 774)

vw - view width

Czoka
  • 118
  • 3
  • 12