# CSS makes the world go round 🌎

On Thursday I came across this really great tweet by [Antonia](https://twitter.com/NanouuSymeon)

%[https://twitter.com/NanouuSymeon/status/1301474015760887813?ref_src=twsrc%5Etfw]

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`

![World round css](https://cdn.hashnode.com/res/hashnode/image/upload/v1599141879816/8sIi0hgsH.gif)

> It's not as smooth as Antonia's example because the world only has three emoji's ☹️

## HTML Structure

Our HTML is the simplest ever. 
Only one div!

```html
<div class="world"></div>
```

## CSS spinning world emoji

As for `CSS` this is where the magic happens!

Let's start my making the body a display flex and [center everything with flex](https://daily-dev-tips.com/posts/css-flexbox-most-easy-center-vertical-and-horizontal/).

```css
body {
  background: #333;
  display: flex;
  height: 100vh;
  align-items: center;
  justify-content: center;
}
```

Next up to our div!

```css
.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](https://daily-dev-tips.com/posts/css-pseudo-elements/) 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:

```css
@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:

```css
@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.

%[https://codepen.io/rebelchris/pen/QWNOwWN]

### Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on [Facebook](https://www.facebook.com/DailyDevTipsBlog) or [Twitter](https://twitter.com/DailyDevTips1)
