Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the & mean in an scss selector?

Tags:

What does & refer to in an scss selector?

      //Case 1      .parent {       & > ul {         color: red       }     }      //Case 2      .parent {       & > ul {         & > li {           color: blue;         }       }      }      //Case 3      .parent {       & > ul {         & > li {           color: blue;           &:hover {             color: pink           }         }       }     }  
like image 395
Zhirayr Avatar asked Aug 06 '16 12:08

Zhirayr


1 Answers

The & is a placeholder for the parent selector:

.parent {   & > ul {     color: red   } } 

Is the same like

.parent > ul {   color: red } 

A common use case are pseudo classes, e.g.:

.link {   &:hover {     color: red   } } 

A nice explanation with examples can be found on CSS Tricks.

like image 168
andreas Avatar answered Oct 17 '22 00:10

andreas