YogeshChauhan . com

How to define variables in SCSS (Sass)?

in SCSS on May 7, 2021

Sass or SCSS variables are similar to PHP variables in one way. Just assign a value to a variable name that starts with a dollar sign ($).

Just like this:


$base-color: #c6538c;

Sass (SCSS) Variables are really helpful in reducing repetition and even complex math calculation.

Sass doesn’t differentiate between hyphens and underscores when it comes to variable names. So, $font-size and $font_size both are like calling the same variable.

The SCSS code above for ‘alert‘ class compiles into this CSS:


.alert {
  border: 1px solid rgba(255, 76, 76, 0.88);
  color: #ff4c4c;
}

amazon

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 How to Use SQL MAX() Function with Dates? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

Jun 16 What are Stored Procedures for SQL Server? Jun 16 What are Class Constants in PHP? Jun 15 A short basic guide on states in React Jun 15 How to define constants in PHP? Jun 15 How to define visibility for a property in PHP? Jun 15 How to use @if and @else in SCSS?

You might also like these

3 Types of Arrays in PHPPHPHow to check if a link has http or https in it in JavaScript?JavaScriptAll different methods for accessing elements in the DOM using JavaScriptJavaScriptOpen Source Security Tools for Defense SecurityMiscThe Differences Between HAVING Clause and WHERE Clause in SQLSQL/MySQLHow to create a smooth scrolling effect with CSS?CSSArray.from() Method in JavaScriptJavaScriptSteps to Secure a VPNMiscAmpersand (Parent Selector) in SCSS (Sass)SCSSIntroduction to Angular modules Part 1: NgModule metadataAngularFull and Partial ROLLUP in Postgresql with ExamplesPostgresWhat is Object Mutability in JavaScript?JavaScript