PBS logo animation with CSS
Tags: css, codepen, showdev, webdev
Published: 2020-02-22 04:10:55


*This was originally published on [codinhood.com](https://codinhood.com/micro/pbs-logo-animation-with-css)*


Whether they grew up watching Mister Rogers, learned to paint with Bob Ross, or just settle in every night to watch the news, the iconic PBS logo is a familiar and comforting sight to many Americans. The logo is successful, in part, due to the measures PBS makes to ensure that their branding is clean, unique, and consistent. In 2019, PBS redesigned their logo with a new official color and custom PBS font that can be found on their [brand guidelines](https://www.pbs.org/brand/) page. The newest design is sleek and modern, but to keep things simple (and because of my overwhelming nostalgia-driven biases) I'm going to show you how to create the [PBS logo from 2002-2019](https://logos.fandom.com/wiki/PBS) with CSS. Click the `Rerun` button at the bottom to see the animation again.

{% codepen https://codepen.io/codypearce/pen/wYrdEK %}

## Background and Font

The blue background, `#00acf1`, used to be the blue background for the official PBS app and other media. The background needs to take up the whole page, so we can use `100vh` to set the height to be 100% of the viewport height. The font from that era was `Caecilia 75 Heavy`, but since this is not available on Google Fonts, we'll use [Bree Serif](https://fonts.google.com/specimen/Bree+Serif). Finally, let's center the logo on the page using flexbox.

```css
@import url("https://fonts.googleapis.com/css?family=Bree+Serif");

body {
  background: #00acf1;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: hidden;
}
.PBS {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}
```

## PBS Back Head

The PBS logo head is a unique shape that can be broken down into a few more basic shapes. First, create the black circle and give it a `position: relative`, so that we can use `position: absolute` to move the individual parts within the black circle easily. The back of the head is essentially a half circle. We can create a half circle in CSS a few ways, but for now, we'll create a full circle and hide the right half.

```html
<div class="PBS__Logo">
  <div class="Logo__head"></div>
</div>
```

```css
.PBS__Logo {
  height: 150px;
  width: 150px;
  border-radius: 100%;
  background: black;
  position: relative;
  z-index: 2;
}

.Logo__head {
  height: 60px;
  width: 80px;
  border-radius: 40px;
  background: white;
  position: absolute;
  left: 30px;
  top: 35px;
}
```

![PBS Head Full Circle](https://codinhood.com/static/64514f2bdb882cc24724a9a5e16a7df7/6eb4e/full-circle.png)

Now, hide the second half by creating a square pseudo-element and positioning it over the second half.

```css
.Logo__head::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 55%;
  background: red;
}
```

![PBS Head Half Circle](https://codinhood.com/static/19c0217a526a00496bf993edf652be8e/969be/half-circle-red.png)

Setting that element to have a black `background` will give the illusion of a half circle:

```css
.Logo__head::after {
  ... background: black;
}
```

![PBS Head Half Circle black](https://codinhood.com/static/f235f31cff55db5e81b2b02ac230e207/77e73/half-circle-black.png)

## PBS Middle Head

You'll notice that this half circle isn't quite wide enough to give the illusion of a fuller circle. To remedy this, we can create a simple rectangle in the middle to give whatever width we need. We need to add large `border-radius` values on the right side so it does not poke out beyond either the forehead or the chin.

```css
.Logo__tophead {
  height: 60px;
  width: 20px;
  background: white;
  position: absolute;
  left: 65px;
  top: 35px;
  border-bottom-right-radius: 20px;
  border-top-right-radius: 10px;
}
```

![PBS Head Middle](https://codinhood.com/static/eb8491792fb0c55bff221bf2a4c14b1a/3128d/middle-head.png)

## PBS Forehead

The forehead might seem difficult to recreate at first, but essentially it is simply a line at a particular angle, or a [parallelogram](https://en.wikipedia.org/wiki/Parallelogram). We can easily create parallelograms in CSS by creating a rectangle and using the CSS transform property, [skew][https://developer.mozilla.org/en-us/docs/web/css/transform-function/skew].

```css
.Logo__forehead {
  height: 40px;
  width: 10px;
  background: white;
  position: absolute;
  left: 84px;
  top: 35px;
  transform: skewX(23deg);
}
```

![PBS Forehead](https://codinhood.com/static/cd78c9d67880fdc364ab9a27eaa56f61/34b33/forehead.png)

## PBS Neck

The neck is probably the most simple shape to create, it's just a white rectangle

```css
.Logo__neck {
  height: 30px;
  width: 30px;
  background: white;
  position: absolute;
  left: 53px;
  top: 85px;
}
```

![PBS Neck](https://codinhood.com/static/efe1cabb62dbf1ee0ef05f5109d2f28d/17add/neck.png)

## PBS Chin

The chin stumped me initially, but on further inspection, it's really a rectangle with a specific `border-radius` value.

```css
.Logo__chin {
  height: 37px;
  width: 17px;
  background: white;
  position: absolute;
  left: 77px;
  top: 57px;
  border-bottom-right-radius: 6px;
}
```

![PBS chin](https://codinhood.com/static/48fa0e62aecdb3dbb4efc69ae02288ce/66c55/chin.png)

## PBS Eye

The eye is really simple as well, it's just a circle positioned correctly with a black `background`.

```css
.Logo__eye {
  height: 15px;
  width: 15px;
  border-radius: 100px;
  background: black;
  position: absolute;
  left: 72px;
  top: 55px;
}
```

![PBS eye](https://codinhood.com/static/4920e0178fbb02c7fe39728883a55f3d/6eb4e/eye.png)

## PBS Double Forehead

The PBS logo contains three faces: the main head face, the floating face, and the negative space face. The floating face is created by using similar shapes to the main head face, while the negative space face is created by positioning the floating face correctly to create the illusion. So, let's start by creating the floating face forehead in a similar way we created the forehead before and position it away from the main head.

![PBS three head](https://codinhood.com/static/73c27aba82d1241ac48956ff9dccc3d8/d0064/three-face.png)

```css
.Logo__doubleForehead {
  height: 40px;
  width: 12px;
  background: white;
  position: absolute;
  left: 106px;
  top: 35px;
  transform: skewX(23deg);
}
```

![PBS double head](https://codinhood.com/static/190750f43c37eb4499bc48c8028c412e/8ab99/double-head.png)

## PBS Double Chin

The double chin is almost identical to the main head chin, copy the original chin and move it over to the right to align with the double forehead.

```css
.Logo__doubleChin {
  height: 20px;
  width: 12px;
  background: white;
  position: absolute;
  left: 106px;
  top: 75px;
  border-bottom-right-radius: 6px;
}
```

![PBS double chin](https://codinhood.com/static/1d03899a6c91c8cfb722ad0828da8649/17add/double-chin.png)

## PBS Double neck

The neck, like before, is simply a rectangle but less wide.

```css
.Logo__doubleNeck {
  height: 20px;
  width: 12px;
  background: white;
  position: absolute;
  left: 96px;
  top: 95px;
}
```

But you'll notice a problem, the double chin and neck should connect on the left side more smoothly.

![PBS double neck](https://codinhood.com/static/72a36c2d1cda8e78e9db1ac5c6d4f5c2/e8d74/double-neck.png)

Creating this more rounded connection is a little tricky because the shape is inward like a parabola rather than outward like a circle. We're going to use the same technique we used for the half circle, create one element and then hide part of it with another. First, create a rectangle with the `::before` pseudo-element on the double chin.

```css
.Logo__doubleChin::before {
  content: "";
  position: absolute;
  bottom: -2px;
  left: -7px;
  background-color: white;
  height: 10px;
  width: 10px;
}
```

![PBS double before](https://codinhood.com/static/8daa8e32a97e573f05f5387d3c7ee30a/e8c3d/double-before.png)

Next, create a `::after` pseudo-element on the double chin that has a `border-radius` on the bottom right. This will be used to "take away" parts of the rectangle we just created to create an inward circle shape.

```css
.Logo__doubleChin::after {
  content: "";
  position: absolute;
  bottom: 0px;
  left: -7px;
  background-color: blue;
  border-bottom-right-radius: 8px;
  height: 10px;
  width: 7px;
}
```

![PBS double after](https://codinhood.com/static/457df61c60fef5026b62ce0d46f4fabe/f5a0a/double-after.png)

Setting the `::after` element to black and the `::before` element to white will create the effect we want.

![PBS double fixed](https://codinhood.com/static/c6f01874bf44494915b6c83416baadd9/34b33/double-fixed.png)

## PBS Letter Animation

We could add the PBS letters by simply creating a `<p>` element and adding the letters in, but we want to animate the letters individually. So put each letter into a different `<span>` element. Additionally, the copyright symbol can be created using the HTML character entity `&reg;`

```html
<div class="PBS__text">
  <span class="PBS__letter">P</span>
  <span class="PBS__letter">B</span>
  <span class="PBS__letter">S</span>
  <span class="PBS__registration">&reg;</span>
</div>
```

Set the letter container to have `position: relative` so we can position the letters and move them around in a boundary box. Additionally, define the styles for the registered trademark.

```css
.PBS__text {
  font-family: "Bree Serif";
  font-size: 68px;
  color: white;
  margin-left: 15px;
  white-space: discard;
  display: flex;
  width: 120px;
  height: 92.92px;
  position: relative;
}
.PBS__registration {
  font-family: "Arial";
  margin-top: 64px;
  margin-left: 0px;
  display: inline-block;
  color: white;
  font-size: 10px;
  font-weight: 200;
  left: 120px;
  position: absolute;
}
```

Since all of the text moves together as a group, we need to animate the whole block of text, `PBS__text`. Create a `slideIn` animation that starts the whole block well within the black circle.

```css
.PBS__text {
  ... animation: 500ms ease-in-out 0ms forwards slideIn;
}
@keyframes slideIn {
  0% {
    transform: translateX(-150px);
  }
  80% {
    transform: translateX(10px);
  }
  100% {
    transform: translateX(0px);
  }
}
```

![PBS animation text](https://codinhood.com/1ac69ff720f5cb1f0126ab5831a5fed4/animation.gif)

## Animate Individual Letters

We want the letters to be scrunched up like they came as a group thrown at the right side of the logo, and then have the P and B animate backwards to their rightful positions. Add `position:absolute` to each so we can set the correct positions throughout the animation. Additionally, add an animation property for the P and B letter separately, because they need to end up at different spots.

```css
.PBS__letter {
  position: absolute;
}
.PBS__letter:nth-child(1) {
  left: 80px;
  animation: 650ms ease-in-out 200ms forwards pLetter;
}
.PBS__letter:nth-child(2) {
  left: 40px;
  animation: 500ms ease-in-out 200ms forwards bLetter;
}
.PBS__letter:nth-child(3) {
  left: 80px;
}
```

You'll notice that the letters are not completely overlapping, but more scrunched up together. Getting this animation to look smooth takes a little practice and experimentation, but play around with the left values here to see where the letters will end up.

```css
@keyframes pLetter {
  0% {
    left: 40px;
  }
  80% {
    left: -2px;
  }
  100% {
    left: 0px;
  }
}
@keyframes bLetter {
  0% {
    left: 60px;
  }
  80% {
    left: 38px;
  }
  100% {
    left: 40px;
  }
}
```

Check out the codepen above for the full animation.

## Conclusion

Breaking complex images down into basic shapes that can be recreated with CSS is a fun and powerful technique to create CSS art. I'm a big fan of PBS and their logo, so I hope creating this logo was as much fun for me as it was for you.