Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sass % operator [duplicate]

Tags:

One of the developers where I work recently left and upon going through his sass code, I found this:

%centerAll {   display: block;   position: relative;   top: 50%;   left: 50%;   -webkit-transform: translate(-50%, -50%);   -ms-transform: translate(-50%, -50%);   transform: translate(-50%, -50%); } 

I'd say I'm pretty experienced with sass but I've never see anything in Sass that uses the modulo operator like that. To make matters stranger, this "mixin" is included through the code as:

@extend %centerAll

and as far as I know, @extend is used for extending the properties of the class, via inheritance.

Has anyone ever seen this before?

like image 960
barndog Avatar asked Oct 08 '15 20:10

barndog


1 Answers

This is a placeholder selector.

They are very similar to class selectors, but instead of using a period (.) at the start, the percent character (%) is used. Placeholder selectors have the additional property that they will not show up in the generated CSS, only the selectors that extend them will be included in the output.

like image 53
camden Avatar answered Sep 26 '22 09:09

camden