📖 Scenario: You are creating a simple webpage using Bootstrap. You want to change the default Bootstrap colors by overriding SASS variables before compiling the CSS.
🎯 Goal: Build a Bootstrap-based webpage that uses custom colors by overriding Bootstrap SASS variables.
📋 What You'll Learn
Create a SASS file that imports Bootstrap
Override the $primary and $secondary color variables with custom colors
Compile the SASS to CSS and link it in an HTML file
Use Bootstrap classes to show the effect of the custom colors
💡 Why This Matters
🌍 Real World
Web developers often customize Bootstrap by overriding SASS variables to match brand colors and design guidelines.
💼 Career
Knowing how to customize Bootstrap with SASS is a valuable skill for frontend developers working on professional websites and applications.
Progress0 / 4 steps
1
Create a SASS file with Bootstrap import
Create a SASS file named custom.scss and write the line @import "bootstrap/scss/bootstrap"; to import Bootstrap styles.
Bootsrap
Hint
Use the @import directive to include Bootstrap's SASS files.
2
Override Bootstrap color variables
In custom.scss, add these two lines $primary: #ff5733; and $secondary: #33c3ff; before the @import line to override Bootstrap's primary and secondary colors.
Bootsrap
Hint
Variable overrides must come before the Bootstrap import line.
3
Create an HTML file linking the compiled CSS
Create an index.html file with a <link> tag in the <head> that links to custom.css, the compiled CSS from your SASS file.
Bootsrap
Hint
Use a <link> tag with rel="stylesheet" and href="custom.css".
4
Add Bootstrap buttons to show custom colors
Inside the <body> of index.html, add two buttons: one with class btn btn-primary and text Primary, and another with class btn btn-secondary and text Secondary.
Bootsrap
Hint
Use Bootstrap button classes btn btn-primary and btn btn-secondary.
Practice
(1/5)
1. What is the correct way to override a Bootstrap SASS variable like $primary color?
easy
A. Set $primary before importing Bootstrap's SASS files
B. Set $primary after importing Bootstrap's SASS files
C. Change the CSS file directly without using SASS variables