I am trying to create a CSS color grid inside 1 HTML element only (something like this https://www.shutterstock.com/image-vector/seamless-pattern-geometries-pastel-colors-518111110). I want to have 1 HTML element like a div of 300px * 300px, and then I want to create this color grid using CSS only. I don't want to create multiple elements using js or any other CSS framework or library.
Currently, I am thinking of using box-shadow (only able to create 1 axis grid) or background-image, but any other suggestions are welcome.
with box-shadow (1 axis grid)
#test {
width: 100px;
height: 100px;
border: 1px solid;
box-shadow: 10px 0px 0 0 red, 20px 0px 0 0 blue;
clip-path: inset(0px -15px 0px 0px);
}
------- edit --------
A lot of people are saying why I want to do it, so here it is. https://youtu.be/-7k3H2GxE5E look at this video of Jake and Surma. Here they talk about the progressive loading of images. I was thinking maybe we can generate a rough sketch grid colors of big images in a webpage, that will give users some insight about the image on slow networks. There are 3 ways to do that, with low res images, creating multiple div in HTML with image data using js, or as the image will be just colored, I was thinking maybe I can try with CSS only. I have already done the first 2, but I want to compare their performance.
"I don't want to create multiple elements using js" because for big images, there will be a lot of HTML nodes and this will have a negative performance impact.
It will be only a visual grid with no interaction.
https://codepen.io/jaysalvat/pen/HaqBf look at this codepen for reference. This guy also created the script for doing this but it's in PHP and we need to install this. I was thinking to create this in browser only with some more useful tools.