dots Created with Sketch.
Yogesh Chauhan's Blog

Create dynamic selectors using SCSS (Sass)

in SCSS on April 25, 2021

To make the CSS Selectors dynamic, we can make use if @mixin rules with interpolation.

@mixin is a wonderful rule SassScript has. It allows you to write style rules that can be used throughout your stylesheet — basically it helps to create reusable styles.

Interpolation is nothing but an expression wrapped in #{}.

Here’s how to do it.

Another example:

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 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Jul 22 Is there a CSS parent selector? #Jul 22 Difference between :where and :is in CSS #Jul 22 Does :is() pseudo selector hint at CSS preprocessing in the future? #Jul 22 Control Scrolling with CSS Scroll Snap #Jul 21 Control rendering using CSS content-visibility property #Jul 21 How to use @supports rule in CSS?
You might also like these
WordPress: How to setup and get values from an ACF options page?WordPressUnary Operators in JavaScriptJavaScriptHow to add a Line Chart in Angular App?Angular2 Ways We Can Write Multiple Line Commands in PHPPHPFive common features of Angular template syntax (with examples)AngularThe Drupal flowDrupalHow to create a cross-browser smooth scrolling with jQuery?jQueryclip and clip-path properties in CSSCSSPHP Login System using PDO Part 2: Login using Email or UsernamePHPHow to set up the local environment and workspace for Angular development?AngularHow to set opacity or transparency using CSS?CSSHow to remove special characters (dash, asterisk etc) from any string in PHP?PHP