Hey everyone,
i am new in grav and twig and have a question.
Is there any possibility to get the screen/browser width and write inside a twig variable?
Greetings
Florian
Hey everyone,
i am new in grav and twig and have a question.
Is there any possibility to get the screen/browser width and write inside a twig variable?
Greetings
Florian
Hello Florian,
You can get some information about the browser from twig using this: https://learn.getgrav.org/themes/theme-vars#browser-object
You can’t get the browser width exactly, but it might be able to do what you want. Be aware that your user might resize his browser though, so you might need to do some stuff in css or javascript.
Hi there @flosse !
You can get exact screen width using JavaScript, but in most cases better idea is to use CSS vh
and vw
units. If you can give us some more about what you’re trying to achieve, I’ll be happy to try to help!