Frontend Development 7 min read

Drawing Peppa Pig with Pure CSS: border-radius Technique Tutorial

An engineer from Tencent shows how to recreate Peppa Pig entirely with pure CSS by exploiting the border‑radius property to craft ellipses, rotate them, layer colors, and mask gaps, providing step‑by‑step code for each body part and a complete, animated illustration.

Tencent Cloud Developer
Tencent Cloud Developer
Tencent Cloud Developer
Drawing Peppa Pig with Pure CSS: border-radius Technique Tutorial

This article demonstrates how to draw the popular cartoon character Peppa Pig using pure CSS techniques, authored by a Tencent network engineer. The author introduces an interesting "Peppa Pig debugging method" as background humor before diving into the technical implementation.

The core technique revolves around the CSS border-radius property, which is typically used for creating rounded corners but can be creatively used to draw complex curved shapes. The author explains that CSS cannot directly draw curves, so the workaround is to use border-radius with specific parameters.

The border-radius property accepts both horizontal and vertical radii separated by a slash, accepting length values or percentages. The syntax border-radius: 5px is equivalent to border-radius: 5px 5px 5px 5px/ 5px 5px 5px 5px , representing the horizontal radius for top-left, top-right, bottom-right, bottom-left, followed by the vertical radius for each corner.

The drawing process involves: 1) Creating ellipses, 2) Adjusting border-radius parameters, 3) Applying colors, 4) Setting rotation angles, and 5) Using layer masking with white and pink backgrounds to fill gaps. The author provides detailed CSS code for the pig's head outline:

position: absolute;
z-index: 100;
box-sizing: border-box;
width: 300px;
height: 200px;
top: 100px;
left: 100px;
border-radius: 92% 50% 50% 50%/ 87% 80% 68% 50%;
border: 6px solid #ef96c2;
background-color: #ffb3da;
transform: rotate(30deg);
transform-origin: left top;

The article provides the complete HTML structure for the entire Peppa Pig drawing, including all body parts: tail, feet, shoes, hands, body, head, ears, nose, jaw, nostrils, eyes, mouth, and cheeks. The final result is compared against the original template from Peppa Pig Season 4.

frontend developmenttutorialcssborder-radiuspure CSS drawingWeb Graphics
Tencent Cloud Developer
Written by

Tencent Cloud Developer

Official Tencent Cloud community account that brings together developers, shares practical tech insights, and fosters an influential tech exchange community.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.