Table of Contents
Intro
I started tinkering with CSS in 2018-20. And took couple CSS (cascading style sheets) courses, intermediate to advance level ones, took the basic one on Khan academy and other ones on udemy. The CSS basic hands-on course on General assembly stands out as I learned more advance CSS manipulation there, along with the maths involved.
CSS art and animation was really awesome, as you could design stuff yourself. It was my first hangover with coding and to make something cool.
Things I designed
My (more or less looking) face
See the Pen CSS Face by Shashwat Verma (@zippytyro) on CodePen.
Here’s the source code and below is the explanation:
- Positioning the Face:
Thecontainerclass ensures the face is centered on the screen usingposition: fixedandtransform: translate(-50%, -50%).
- Face Structure: The
faceclass defines the main facial structure with rounded corners (border-radius) and a light peach background color.
- Facial Angles:
f-angle2andf-angle1create angular details on the face using rotated rectangles with specific border-radius values.
- Hair Styling:
hairandlinecreate a simple hair design with a dark brown color, using borders for styling.
- Eye Styling:
eye1andeye2define the eyes with a black background, giving them a circular appearance usingborder-radius: 50%.
- Ear Design:
ear1andear2use rotated rectangles to create ears with a light peach color.
- Nose Detail:
Thenoseclass adds a simple, neutral-colored nose to the face.
- Mouth Design:
mouthforms the mouth using a rotated circular shape with a red-orange border.
- Eyeball Styling:
eyeball-oneandeyeball-twocreate white circular shapes representing the eyeballs.
- Background and Font Styling:
Thebodyclass sets a gradient background, and thepclass styles text at the bottom with a white color, centered alignment, and a specific font-family.
Yin-Yang symbol with hover animation
See the Pen Yin Yang with animation by Shashwat Verma (@zippytyro) on CodePen.
Code explanation:
- Background Styling:The
bodyelement sets the background color to a light purple shade (rgb(204, 132, 252)).
- Container Positioning: The
.containerclass is positioned absolutely, centered both horizontally and vertically usingtransform: translate(-50%, -50%),top: 50%, andleft: 50%.
- Yin Yang Symbol Styling: The
.ballclass styles the yin yang symbol using a circular div with alternating black and white segments, achieved through borders and positioning.
- Inner White Circle: The
.ball::beforepseudo-element represents the inner white circle of the yin yang symbol, using absolute positioning and borders.
- Inner Black Circle: The
.ball::afterpseudo-element represents the inner black circle of the yin yang symbol, using similar techniques as the white circle.
- Text Styling: The
.tclass styles the accompanying text with center alignment, increased font size (1.5em), and a monospace font family. A margin is added to the top for spacing.
- Hover Animation: The
.ball:hoverselector applies a rotation animation (round) on hover, creating a spinning effect.
- Rotation Animation: The
@keyframes roundrule defines a rotation animation from 0 to 360 degrees, creating a complete spin effect for the yin yang symbol.
Conclusion
It’s interesting to design something purely out of code, CSS makes it possible. The latest features of CSS are even more interesting and worth learning. Although, CSS art being a niche thing I was intrigued by it which made me to learn more.
Read more development articles here.
