CSS makes the world go round π

I'm a full-stack developer from South Africa πΏπ¦. I love writing about JavaScript, HTML and CSS.
Search for a command to run...

I'm a full-stack developer from South Africa πΏπ¦. I love writing about JavaScript, HTML and CSS.
You can make the animation sliiiightly smoother, by adding "in between" frames by creating a crossfade layer that displays in bewteen the current frames.
Say, add a ::before pseudo element to .world, layer it directly on top of the ::after, and give it the following keyframes:
@keyframes world-tween{
16.5% {
content: 'π';
opacity: .5;
}
33% {
opacity: 0;
}
50% {
content: 'π';
opacity: .5;
}
66% {
opacity: 0;
}
83% {
content: 'π';
opacity: .5;
}
}
Wow Spencer, golden tip buddy!
That looks way better, going to update the code man!
Most of you know me for my consistency, a golden arrow in my blog series. I've written 1000 articles in 1008 days! Almost an article a day, and my honeymoon was the only holiday I ever took. I'm super proud of this achievement; it has been a fantasti...

It's not the first time I'll be talking about community. I think it's an essential aspect of any successful tool. This shows in my previous explorations of Astro, Medusa, and now Vendure as well. All these products thrive in a super open, welcoming, ...

The cool part about Vendure is how easy it is to set up and how abstract each layer is. Basically, we get the following elements: External database Server Worker Admin UI Frontend While this is amazing, it also brings a bit of complexity when it co...

The previous article looked at customizing Vendure on a data and process level. In this article, we'll look at customizing emails, as they are often a big part of a webshop system. We'll be looking at two different layers of customization for customi...

Even though Vendure is a pretty significant project out of the box, in some cases, we might want to go in and modify some elements to work to our specific use case. In this article, I'll take a high-level look at some elements we can customize within...

On Thursday I came across this really great tweet by Antonia
And I was inspired by it, so I wanted to have a look at this! (Yes, I'm addicted to smileys!)
So today we'll make the world go round with CSS

It's not as smooth as Antonia's example because the world only has three emoji's βΉοΈ
Our HTML is the simplest ever. Only one div!
<div class="world"></div>
As for CSS this is where the magic happens!
Let's start my making the body a display flex and center everything with flex.
body {
background: #333;
display: flex;
height: 100vh;
align-items: center;
justify-content: center;
}
Next up to our div!
.world {
font-size: 250px;
width: 250px;
height: 328px;
}
.world::before {
position: absolute;
content: "π";
z-index: 1;
animation: world-tween 1s infinite;
}
.world::after {
position: absolute;
content: "π";
animation: world 1s infinite;
}
We make the font-size really big and set our starting emoji π on our pseudo after class.
Then we set our animation to be world, for a duration of 1 second and loop forever!
All we need to do now is make the world animation:
@keyframes world {
33% {
content: 'π';
}
66% {
content: 'π';
}
}
Spencer, mentioned we can actually have another layer on top of this, which can hold a tween animation including opacity to make it slightly smoother.
We added a ::before pseudo element to make this happen.
And for our world-tween animation:
@keyframes world-tween {
16.5% {
content: "π";
opacity: 0.5;
}
33% {
opacity: 0;
}
50% {
content: "π";
opacity: 0.5;
}
66% {
opacity: 0;
}
83% {
content: "π";
opacity: 0.5;
}
}
There are only two world emoji's left, so we split our animation in two, and set our content!
That's it, CSS can make the world go round!
View this demo on Codepen.
Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter