Luigi in CSS
Tags: css, codepen, webdev, showdev
Published: 2020-04-10 16:39:46


Always the second fiddle, Luigi deserves some love. Inspired by this great [dribble illustration](https://dribbble.com/shots/1135988-Flat-Luigi-Wallpaper), check out how I recreated Luigi in CSS below using a series of ovals.

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

*This was originally published on [codinhood.com](https://codinhood.com/post/luigi-css)*


## Luigi's Hat CSS

Stripping away all the details on the hat, you end up with what is essentially a fat egg shape that is thicker on the bottom. We can create this shape in CSS by providing 8 values to the `border-radius` property, which allows us to customize the height and width of each corner's `border-radius`. Check out the [W3C spec on border-radius](https://www.w3.org/TR/css-backgrounds-3/#border-radius) to learn more about this technique.

```html
<div class="Luigi">
  <div class="Luigi__hat"></div>
</div>
```

```css
.Luigi {
  height: 400px;
  width: 400px;
  position: relative;
}
.Luigi__hat {
  margin-left: calc(50% - 125px);
  height: 250px;
  width: 250px;
  background: #1ca42f;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  position: relative;
}
```

![Luigis Hat CSS](https://codinhood.com/static/337e8d4b81c73ddddb4db44d0e35a877/64481/luigi-hat.png)

### Luigi Hat Logo CSS

The capital "L" logo is a little more complicated than it looks, because both the stem and branch of the "L" are different sizes, thicker on one end, and rotated slightly. Getting this to look right took a few iterations and pseudo-elements.

```html
<div class="Luigi__hat">
  <div class="Luigi__logo">
    <div class="Luigi__stem"></div>
    <div class="Luigi__branch"></div>
  </div>
</div>
```

```css
.Luigi__logo {
  background: white;
  width: 80px;
  height: 80px;
  border-radius: 100%;
  left: calc(50% - 40px);
  top: 25px;
  position: absolute;
}
.Luigi__stem {
  position: absolute;
  top: 8px;
  left: calc(50% - 15px);
  height: 45px;
  width: 16px;
  background: #1ca42f;
  border-radius: 1px;
}
.Luigi__stem::before {
  content: "";
  position: absolute;
  height: 2px;
  width: 12px;
  top: -1px;
  background: white;
  transform: rotate(-5deg);
}
.Luigi__stem::after {
  content: "";
  position: absolute;
  height: 40px;
  width: 5px;
  top: 0px;
  left: 12.33px;
  background: white;
  transform: rotate(3deg);
}
.Luigi__branch {
  position: absolute;
  top: 45px;
  left: 25px;
  height: 11px;
  width: 33px;
  background: #1ca42f;
  border-radius: 1px;
}
.Luigi__branch::before {
  content: "";
  position: absolute;
  height: 3px;
  width: 20px;
  top: -2px;
  left: 11.5px;
  background: white;
  transform: rotate(-5deg);
}
```

![Luigi's Hat Logo CSS](https://codinhood.com/static/1ef96908a26ddbb4053294f91e1521bf/573ad/luigi-logo2.png)

### Luigi's cap CSS

The cap is an oval shape with a darker inside oval to give the illusion of being "inside" the cap. The illusion won't really work until we put ahead in there, but it should overlap the white part of the logo to help give the illusion of depth on the hat.

```html
<div class="Luigi__hat">
  <div class="Luigi__logo">
    <div class="Luigi__stem"></div>
    <div class="Luigi__branch"></div>
  </div>
  <div class="Luigi__cap "></div>
</div>
```

```css
.Luigi__cap {
  position: absolute;
  left: calc(50% - 85px);
  top: 105px;
  width: 170px;
  height: 140px;
  border-radius: 50%;
  background: #025a10;
  box-shadow: 0 -0.8em 0 0 #32b744;
}
```

![Luigi's Cap CSS](https://codinhood.com/static/e33dc7c1b9cc11e7580e52e7f71e8e81/fc205/luigi-cap.png)

## Luigi's Ears CSS

Luigi's ears are ovals with specific `border-radius`'s on either side. The side of the ear closest to the face is less rounded while the outside of the ear is more rounded. We can use the `border-radius` shorthand to define each corner of the oval to create this shape as shown below.

```html
<div class="Luigi">
  <div class="Luigi__ear Luigi__ear--left"></div>
  <div class="Luigi__ear Luigi__ear--right"></div>
  ...
</div>
```

```css
.Luigi__ear {
  background: #f8ccb3;
  width: 50px;
  height: 75px;
  left: 80px;
  top: 200px;
  position: absolute;
  border-radius: 50% 40% 40% 90%;
  overflow: hidden;
}
.Luigi__ear--right {
  left: 270px;
  border-radius: 40% 50% 90% 40%;
}

.Luigi__ear--left::after {
  content: "";
  height: 60px;
  width: 40px;
  background: #e5b69b;
  position: absolute;
  right: -5px;
  top: 5px;
  border-radius: 50% 40% 40% 90%;
}

.Luigi__ear--right::after {
  content: "";
  height: 60px;
  width: 40px;
  background: #e5b69b;
  position: absolute;
  left: -5px;
  top: 5px;
  border-radius: 40% 50% 90% 40%;
}
```

![Luigi's Ears](https://codinhood.com/static/7fdd7ddaf4097d6a88096d9980929989/c9287/luigi-ears.png)

## Luigi's Face CSS

Hopefully, at this point, you've realized that I'm probably going to use an oval with `border-radius` to create Luigi's face, in which case, you're absolutely right. We can create the five-o-clock shadow by adding a vertical `linear-gradient` that does not blend.

```html
<div class="Luigi">
  ...
  <div class="Luigi__face"></div>
</div>
```

```css
.Luigi__face {
  background-image: linear-gradient(to bottom, #f8ccb3 50%, #ecb494 50%);
  height: 250px;
  width: 175px;
  position: absolute;
  top: 115px;
  left: calc(50% - 87.5px);
  border-radius: 100%;
  z-index: 1;
}
```

![Luigi's Face](https://codinhood.com/static/2f9c48f714585e3d434b431d4d732f01/50cab/luigi-face.png)

### Luigi's Eyebrows CSS

Luigi's eyebrows are essentially fat arcs that taper off on the side very quickly. We can create this effect in CSS by first creating a regular circle in CSS:

![Luigi's Eyebrow 1](https://codinhood.com/static/b204b714cb5fb7cf743d4b7fa142b05f/9ea35/luigi-eyebrow1.png)

Then creating another circle that overlaps the first circle:

![Luigi's Eyebrow 2](https://codinhood.com/static/8a31cdf1b2cb6b3e8bfb931136c0a8e8/4cb19/luigi-eyebrow2.png)

Then changing the overlapping circle to match the color of the background to create the illusion of "cutting out" the original circle:

![Luigi's Eyebrows CSS](https://codinhood.com/static/b3ad78c80e915839e618e1e327225f46/641d0/luigi-eyebrows.png)

The second circle that overlaps the first is created with the `::after` pseudo-element, but you could easily just create another full element.

```html
<div class="Luigi__eyebrow"></div>
<div class="Luigi__eyebrow Luigi__eyebrow--right"></div>
```

```css
.Luigi__eyebrow {
  width: 40px;
  height: 43px;
  border-radius: 100%;
  background: #2e0400;
  position: absolute;
  left: 37px;
  top: 10px;
  transform: rotate(10deg);
}
.Luigi__eyebrow::after {
  content: "";
  background: #f8ccb3;
  position: absolute;
  bottom: -10px;
  left: 3px;
  height: 40px;
  width: 45px;
  border-radius: 100%;
}
.Luigi__eyebrow--right {
  left: 97px;
  transform: rotate(-10deg);
}
.Luigi__eyebrow--right::after {
  right: 4px;
  left: auto;
}
```

### Luigi Eyes CSS

The eyes are really just nested ovals (see a pattern yet?) with different colors at specific positions.

```html
<div class="Luigi__eye">
  <div class="Luigi__iris">
    <div class="Luigi__pupil"></div>
  </div>
</div>
<div class="Luigi__eye Luigi__eye--right">
  <div class="Luigi__iris Luigi__iris--right ">
    <div class="Luigi__pupil Luigi__pupil--right"></div>
  </div>
</div>
```

```css
.Luigi__eye {
  background: white;
  height: 70px;
  width: 45px;
  border-radius: 100%;
  position: absolute;
  left: 35px;
  top: 40px;
  overflow: hidden;
  z-index: 2;
}
.Luigi__eye--right {
  left: 95px;
}
.Luigi__iris {
  width: 35px;
  height: 55px;
  background: #2ba7d1;
  border-radius: 100%;
  right: -2px;
  bottom: 7px;
  position: absolute;
}

.Luigi__iris--right {
  left: -2px;
  right: auto;
}

.Luigi__pupil {
  width: 23px;
  height: 40px;
  background: black;
  border-radius: 100%;
  right: 4px;
  bottom: 7px;
  position: absolute;
}
.Luigi__pupil::before {
  content: "";
  position: absolute;
  background: white;
  height: 10px;
  width: 10px;
  border-radius: 100%;
  left: 5px;
  top: 5px;
}
.Luigi__pupil--right {
  right: auto;
  left: 4px;
}
```

![Luigi's Eyes CSS](https://codinhood.com/static/fa6e53bfdfbb5fdb8648ef9fb2865dea/3a850/luigi-eyes.png)

### Luigi's Nose CSS

Luigi's nose, like most other elements in this image, is an oval with slightly different `border-radius` values for each side. Position the nose over the eyes to create some depth as well.

```html
<div class="Luigi">
  ...
  <div class="Luigi__nose"></div>
  ...
</div>
```

```css
.Luigi__nose {
  width: 84px;
  height: 84px;
  border-radius: 50% 50% 60% 60%;
  background: #f6b996;
  position: absolute;
  left: calc(50% - 42px);
  top: 86px;
  z-index: 3;
}
```

![Luigi's Nose CSS](https://codinhood.com/static/71404ad0c3572267e1eabe36b0d74365/6e43c/luigi-nose.png)

## Luigi's Mustache CSS

We've come to the most important part of the face: the mustache. The mustache really brings the whole image together so it's important to get right. We're going to start with an oval:

![Luigi's Mustache 1 CSS](https://codinhood.com/static/05442f395e9c01b005aae53d36100935/8abfd/luigi-mustache1.png)

Then we're going to create two more large ovals on either side of the main oval using multiple `box-shadows`, check out the image to see the placement.

```css
box-shadow: -2.25em 1em 0 red, 2.25em 1em 0 blue;
```

![Luigi's Mustache 2 CSS](https://codinhood.com/static/27fc4b72e1ff805aebe9f5407d008a21/153fa/luigi-mustache2.png)

The blue and red colors are just placeholders so you can distinguish the shapes better. Next, we're going to create another oval that spans across all three ovals on the top. This oval will have the same color as Luigi's skin, while the two `box-shadow` ovals should be changed to the color of the mustache.

![Luigi's Mustache 3 CSS](https://codinhood.com/static/88c6595fe9f737b1f87975839679f063/83930/luigi-mustache3.png)

The top oval will blend in with Luigi's skin on either side of his nose to give the illusion of cutting away the ovals, similar to his eyebrows. Finally, we need to place the mustache under his nose but above his chin.

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

```css
.Luigi__mustache {
  position: absolute;
  top: 73px;
  left: calc(50% - 55px);
  height: 96px;
  width: 110px;
  border-radius: 50%;
  background: #2e0400;
  box-shadow: -2.25em 1em 0 #2e0400, 2.25em 1em 0 #2e0400;
}

.Luigi__mustache::after {
  content: "";
  position: absolute;
  top: 0em;
  left: calc(50% - 85px);
  height: 60px;
  width: 170px;
  border-radius: 50%;
  background: #f8ccb3;
}
```

![Luigi in CSS](https://codinhood.com/static/1c4dbf68879814d11225ed9dd658afef/14e05/cover4.png)

If you liked this CSS demo, you also might like [Draw and Animate Bender's Face with CSS](https://codinhood.com/micro/draw-animate-benders-face-css) or [Animate Octocat swimming with CSS](https://codinhood.com/micro/animate-octocat-sprite-css).