Yogesh Chauhan's Blog

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;
}


Most Read

#1 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
Canvas Drawing in HTML5HTMLWhere is the PHP log file located on Mac OS?PHPHow to show widgets on the Appearance tab in WordPress?WordPressWindow setInterval() Method in JavaScriptJavaScriptHow to create ‘share on LinkedIn’ link using just HTML?HTMLtransform-origin Property in CSSCSSSafe Practice to add Links to cross-origin destinationUI/UXHow to reference an aliased column in the WHERE clause?SQL/MySQLSQL ALL OperatorSQL/MySQLThe basics of @import rule in SCSS (Sass)SCSSSQL Inner JoinSQL/MySQLHow to show and hide an element on click in React?React