Logo LIBR
Halo

Portfolio

Back to Blog
9 min read
AnimationsMay 27, 2025

CSS Advanced: Animations, Responsive Design & Best Practices

CSS, Animations, Responsive Design
Syifa Fauziyah Arizal

Master advanced CSS techniques including animations, transitions, responsive units, and professional styling best practices.

If HTML is the foundation, CSS Card 4 is like Instagram filters for your website. Making it alive, moving, and adaptive.

Pseudo-Class & Pseudo-Element

Pseudo-Class (:)

Used to style elements based on their state (when clicked, hovered, etc).

ExampleFunction
:hoverWhen element is touched/hovered
:focusWhen element is active (like clicked input)
:first-childFirst child of parent
:nth-child(2)2nd child
CSS
button:hover {
  background-color: hotpink;
  color: white;
}

Pseudo-Element (::)

Styles part of an element, not the whole element.

ExampleFunction
::beforeAdd content before element
::afterAdd content after element
::placeholderStyle input placeholder
CSS
h1::after {
  content: " 🚀";
  color: orange;
}

Transitions & Light Animations

transition

Creates smooth effects when properties change.

CSS
.box {
  transition: all 0.3s ease;
}

.box:hover {
  transform: scale(1.1);
  background-color: #00f;
}

Zoom effect on hover. Smooth and soft, not like Harry Potter magic.

animation

Creates repeating/regular movement using keyframes.

CSS
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.title {
  animation: fadeIn 1s ease-in;
}

Responsive Units

Popular Units

UnitFunction
pxFixed size
%Relative to parent element
emRelative to parent's font size
remRelative to root (html)
vw / vh% of viewport width/height
CSS
.container {
  width: 80vw;
  font-size: 1.2rem;
}

Best practice: use rem for text, vw/% for layout. Responsive layouts become much easier this way.

Responsive Design + Media Query

media query = way to create different displays for different screen sizes.

CSS
@media (max-width: 600px) {
  h1 {
    font-size: 24px;
    text-align: center;
  }
}

Mobile user? Display automatically neat. Laptop user? Still looks good.

Styling Best Practices (Must Know to Go Pro)

TipExplanation
Use classes, avoid styling tags directly like <h1>More flexible
Clear class names (.btn-primary)Less confusing
Reuse classes, avoid copy-paste stylesDRY: Don't Repeat Yourself
Use CSS reset/normalizeConsistent display across browsers
External CSS > inline/internalCleaner and more scalable

Closing Thoughts from Me - LIBR

Hi! I'm Syifa, and all the material I share here is what I've learned from SCRATCH.

I started not knowing what <div> was, why we need <head>, or why CSS could change text colors. But little by little I learned through videos, articles, and of course, lots of trial and error until the errors disappeared.

Everything I share here (from HTML Card Part 1–2 to CSS Card Part 1–4) is my own recap and understanding. I try to explain it in a way I understand and like, so readers can feel: "Oh, it can be explained this simply."

I believe:
Learning to code isn't about who's fastest, but who's consistent and doesn't give up.

If you're also learning HTML & CSS from scratch, I hope this content can be your learning companion too.

Don't be afraid to start from the bottom, everyone who's good was once stuck on just <br>.

CSS Recap Card 4

  • Know pseudo-class/pseudo-element for cool interactions and effects
  • Can create hover effects and simple animations (without JavaScript!)
  • Familiar with various units (px, rem, %, vw, etc)
  • Responsive layout works through media queries
  • Ready to style like a pro with best practices

More to read