-3
I need to change the variable value of a function according to the screen resolution (when reducing the screen the value has to be updated immediately). You can change this value through CSS media queries?
I mean, something like this with css:
@media only screen and (max-width: 1065px) {
$variavel = 3;
}
@media only screen and (max-width: 769px) {
$variavel = 2;
}
To recover the value in php:
catalogo($variavel)
;
Is there any way to do this?
Thank you
This query does not make much sense. There is no "PHP variable" when the client is accessing the page. There is only PHP while the server mounts the content. Then it goes to the browser, where the darlings will be processed. At most, what you can do is send the screen width via JS or something like that to another PHP store.
– Bacco
Dude, there’s no way you can do it this way no... PHP and CSS don’t match like you think. The ideal would be to take the screen size through Javascript and then pass to PHP, this is possible.
– KhaosDoctor
Thanks for the answers, I will think of another way to do what I need. Thanks also for the suggestions.
– Tiago Pereira
@Tiagopereira what the purpose of this code is. Tell us what you intend to do. Maybe we can point a way.
– Thomas Lima
Damn, use a Less or a Sass :D
– Wallace Maxters