How to make single div(any element) CSS art - A mini thread ๐Ÿงต

Spoiler: No magic ๐Ÿช„ All that's required is patience and knowing your way around some properties ๐Ÿ‘

Let's gooo! ๐Ÿ‘‡

Starting with this timelapse โณ

The "Big" trick? Layered background images ๐Ÿ˜ฎ

With CSS you can give many backgrounds to an element. Comma separate background images and you're golden โœจ๐Ÿ†

What would this give for a 60px square? ๐Ÿค”

๐Ÿ‘‰ https://t.co/3N2SzXNn61
It's common that you'll not repeat your background image layers.

Don't repeat yourself(DRY) and drop:

"background-repeat: no-repeat;"

Beneath your background declaration ๐Ÿ‘๐Ÿ˜Ž
If you watched the timelapse above, it slows where the order of background images are swapped ๐Ÿค”

Layered backgrounds are a little counter-intuitive because they work the opposite way to z-index stacking. The first is the highest, the last the lowest.

Save the last for backdrop!
What shapes can we make? Pretty much anything that we can > 1 element ๐Ÿ˜Ž

Examples? Create quadrilaterals using a linear-gradient from one color to the same color. Create circles with a radial-gradient from one color to transparent with a color stop.

https://t.co/x6ZfnaBrV7
How about a triangle?

1. Use a linear-gradient.
2. One side transparent, the other the color you want.
3. Define the angle.
4. Use a color stop to create a sharp line ๐Ÿ’ช

https://t.co/wlZ1RC6m7n
Get comfortable with the background-image property ๐Ÿ˜Ž
If a shape seems complex, break it down into smaller shapes and layer up ๐Ÿ‘

Consider the spectacles in the demo above. It's 11 background images positioned accordingly. 4 for each frame, 1 for the bridge, 1 for each lens ๐Ÿ‘
Which leads to an important part!

background-size && background-position are what allow you to create and move the building blocks around your element ๐Ÿ’ช

We are using the shorthand style structure for the backgrounds.

We could break it up but that gets confusing!
Check out this demo where you can change the background-position and background-size for a background-image ๐Ÿ‘๐Ÿ˜Ž

Try changing the coefficients or the bounds and see how it reacts ๐Ÿค“

๐Ÿ‘‰ https://t.co/sls8iMlsdR
That's the bulk of the "magic" behind single element CSS art ๐Ÿ™Œ

But, it's worth discussing some tips to make life a little easier ๐Ÿ˜Ž
Split your background images up into variables ๐Ÿ‘๐Ÿ˜Ž

Then you can easily identify what's what. Consider this demo. Each component is identifiable. It also makes switching the order around much easier to see ๐Ÿ˜Ž

Try changing some property values ๐Ÿ˜‰

https://t.co/3MtGGIihjs
Using CSS variables to power things is huge ๐Ÿ’ช

In that demo, you can control sizing, colors, features, etc. โœจ

Because of scope, you can generate many unique combinations by using JavaScript. Consider the 100
demo ๐Ÿ˜Ž

https://t.co/fxPFWVE83b
In the 100
demo, JavaScript generates inline variables for every element. That means so many unique combinations get generated.

Find the "for" loop on line 170 and you can change the number of people generated ๐Ÿ˜‰

Or check out this demo ๐Ÿ˜Ž

https://t.co/506EoRFrbl
Last but not least ๐Ÿ˜…

You've got more than you think ๐Ÿ‘€ Need a transform or a rotate? Running out of room?

For most elements, you also get two elements for free! ๐Ÿ˜Ž

The pseudo-elements :after and :before ๐Ÿ‘

https://t.co/NtXjz1XHvw
That's it!

A spontaneous mini-thread about drawing things in CSS with a single element ๐Ÿ˜…

Had a few questions about the "100 Members of HR" demo and figured I'd throw something together.

The gist: Layer up background images! Layer! Layer! Layer! ๐Ÿ˜‚
Got any other tips or tricks you use?

Still not sure about how to do something?

Let me know! ๐Ÿ˜„

You May Also Like

First thread of the year because I have time during MCO. As requested, a thread on the gods and spirits of Malay folk religion. Some are indigenous, some are of Indian origin, some have Islamic


Before I begin, it might be worth explaining the Malay conception of the spirit world. At its deepest level, Malay religious belief is animist. All living beings and even certain objects are said to have a soul. Natural phenomena are either controlled by or personified as spirits

Although these beings had to be respected, not all of them were powerful enough to be considered gods. Offerings would be made to the spirits that had greater influence on human life. Spells and incantations would invoke their


Two known examples of such elemental spirits that had god-like status are Raja Angin (king of the wind) and Mambang Tali Arus (spirit of river currents). There were undoubtedly many more which have been lost to time

Contact with ancient India brought the influence of Hinduism and Buddhism to SEA. What we now call Hinduism similarly developed in India out of native animism and the more formal Vedic tradition. This can be seen in the multitude of sacred animals and location-specific Hindu gods