CSS Advanced: Animations, Responsive Design & Best Practices

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).

Example Function
: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.

Example Function
::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:

Unit Function
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 = YESSS ๐Ÿ”ฅ

๐ŸŽจ 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 cool.

๐Ÿงผ Styling Best Practices (Must Know to Go Pro)

Tip Explanation
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

๐Ÿง  CSS Recap Card 4

  • Know pseudo-class/element for cool interactions & effects
  • Can create hover effects & 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

๐Ÿ“Œ Closing Thoughts from Me - SICODER ๐Ÿ’ป๐ŸŒฑ

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 you 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, from knowing nothing - 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> ๐Ÿ˜†

Logo SICODER