I'm currently trying to make a css background that will change size depending on the size of the screen, so I tried to use a variable like that :
var root = document.documentElement;
document.addEventListener('resize', () => {
root.style.setProperty('--screen-x', window.screenX)
root.style.setProperty('--screen-y', window.screenY)
})
#element {
background-image: url(https://picsum.photos/var(--screen-x)/var(--screen-y)?random=3);
}
Btw, there is 4 differents elements with the random from 1 to 4 to get 4 separate images with picsum.
Sorry if I'm not clear, english is not my first langage :(
It obviously doesn't work, but I wonder if there would be a way to do it ? (get the variables in the url)