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> πŸ˜†

πŸš€ What's Next?

Meet JavaScript
"HTML is the skeleton, CSS is the outfit... JavaScript? That's the soul!"
What is JavaScript? Β· Why JavaScript is important in web dev Β· How to use JS in HTML Β· etc

πŸš€ What's Next?

Logic, Conditions & Loops
"This is where your website starts to 'think'."
Branching: if, else, else if Β· Switch case (for alternative branching logic) Β· etc

πŸš€ What's Next?

Interactions & Basic DOM
"Time to make your website alive! Can click, change text, and control display directly from script."
What is DOM (Document Object Model) Β· Event Listeners (click, input, etc) Β· etc

πŸ“Stay tuned!
πŸ“© Just DM if you're also learning to code - we can grow together!

Your Logo