Currently, I am in the process of developing a game using HTML/CSS/JavaScript. My background is currently set to a single image (100px / 100px) being repeated vertically and horizontally to tile across the entire page body;
CSS:
body {
background-image: url("./assets/bgImage.png");
background-repeat: repeat;
}
It works well and functions as intended.
I am wondering if it's feasible to create an array of images to choose from and have each repetition of CSS randomly select one of the images from the array to fill into the next slot. If this is possible, how can it be achieved? The desired outcome is illustrated below (minus the margins);
https://i.sstatic.net/mlxez.png https://i.sstatic.net/dwkth.png
https://i.sstatic.net/M9GML.png https://i.sstatic.net/mlxez.png
The only method that comes to mind for achieving this would involve using
<div style="position: absolute; z-index: -1;">
and then populating it with a generated array of images. While that approach is viable and I could implement it that way, I want to explore simpler and more effective alternatives first.