Use screen.width inside calc (css)

Sefean picture Sefean · Aug 9, 2017 · Viewed 28.3k times · Source

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.

Answer

Ehsan picture Ehsan · Aug 9, 2017

100vw = 100% of viewport width

left:calc(250px + 100vw - 1024px)!important;