Gradients
๐ Covered in this chapter:
Linear Gradient ยท Direction ยท Color Stops ยท Radial ยท Conic ยท Gradient Backgrounds ยท Gradient Borders ยท Gradient Text ยท Overlays ยท Performance
Welcome to Chapter 31: Gradients โ part of the CSS Complete Roadmap. This lesson covers all subtopics with clear explanations, code examples, and best practices used in professional web development.
1Linear & Radial Gradients
.gradient-bg {
background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
}
.radial-bg {
background: radial-gradient(circle at top left, #eff6ff, #dbeafe);
}
.conic-badge {
background: conic-gradient(from 180deg, #2563eb, #7c3aed, #2563eb);
}
Color stops: linear-gradient(to right, red 0%, yellow 50%, green 100%)
2Gradient Borders, Text & Performance
CSS
.gradient-text {
background: linear-gradient(90deg, #2563eb, #7c3aed);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.gradient-border {
border: 2px solid transparent;
background: linear-gradient(#fff, #fff) padding-box,
linear-gradient(135deg, #2563eb, #7c3aed) border-box;
}
Performance: CSS gradients GPU-friendly โ large image backgrounds kante often faster. Complex animated gradients CPU use cheyochu.