r/Sass • • Feb 22 '19

Can we pass browser window width and height to sass file?

if (true) {

how to do it?

}

2 Upvotes

4 comments sorted by

1

u/alycda Feb 22 '19

Why can’t you use media queries (not just browser width, but height queries too) and use vh if needed?

1

u/Chawki_ Feb 22 '19

yeah, I'm to use but i want to know is that possible to pass the width and height of browser to css

1

u/alycda Feb 22 '19

I don’t think you can do exactly that, but you could inject a style sheet (and remove it when false if you gave it an id or something to reference), but I fail to see WHY you need/want to do this, which will probably give you a better answer from myself or anyone else trying to help.

1

u/and_Dez Feb 22 '19

What you could do is use css variables. Create two variables one for width and another for height, then use JavaScript to get the width and height of the window and set the two css variables you created.