Skip to content

Latest commit

 

History

History
108 lines (77 loc) · 1.68 KB

CSS-advanced.md

File metadata and controls

108 lines (77 loc) · 1.68 KB

Advanced CSS Topics

Table of Contents

  1. CSS Animations
  2. CSS Transitions
  3. Pseudo-classes
  4. CSS Variables
  5. Responsive Design
  6. Further Reading

CSS Animations

CSS animations make it possible to animate transitions from one CSS style to another.

@keyframes my-animation {
  from {
    background-color: red;
  }
  to {
    background-color: yellow;
  }
}

.animate {
  animation: my-animation 4s infinite;
}

CSS Transitions

Transitions provide a way to control animation speed when changing CSS properties.

.transition {
  transition: background-color 0.5s ease;
}

.transition:hover {
  background-color: green;
}

Pseudo-classes

Pseudo-classes are used to define the special state of an element.

/* Hover state */
a:hover {
  color: red;
}

/* First child of a parent */
p:first-child {
  font-weight: bold;
}

CSS Variables

CSS variables, also known as custom properties, allow you to store reusable values.

:root {
  --main-color: blue;
}

.element {
  background-color: var(--main-color);
}

Responsive Design

Responsive design aims to make websites look good on all devices.

/* Mobile-first approach */
@media only screen and (min-width: 600px) {
  .container {
    width: 80%;
  }
}

Further Reading

Ready to dive deeper? Check out these free resources: