Lighten and Darken Colors with Sass
📖 Scenario: You are creating a simple style sheet for a website. You want to use Sass functions to make colors lighter or darker easily. This helps keep your design consistent and easy to update.
🎯 Goal: Build a Sass file that defines a base color, sets a percentage for lightening and darkening, then uses the lighten() and darken() functions to create lighter and darker color variants. Finally, apply these colors to CSS classes.
📋 What You'll Learn
Create a variable
$base-color with the exact value #3498dbCreate a variable
$change-percent with the exact value 20%Use the
lighten() function with $base-color and $change-percent to create $light-colorUse the
darken() function with $base-color and $change-percent to create $dark-colorCreate CSS classes
.light and .dark that use $light-color and $dark-color as background colors respectively💡 Why This Matters
🌍 Real World
Designers and developers often need to create color palettes with consistent light and dark shades for buttons, backgrounds, and themes.
💼 Career
Knowing how to use Sass functions like lighten() and darken() helps you write maintainable and scalable CSS for professional web projects.
Progress0 / 4 steps