S
S
Sasha2015-12-23 09:08:36
Layout
Sasha, 2015-12-23 09:08:36

Which method is better to use @extend % template or @extend .class?

Hello.
Which method is better to use, more convenient, which takes less time to compile?
@extend %template or @extend .class ?
If I'm not mistaken, they work the same way.
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
timfcsm, 2015-12-23
@timfcsm

the template extend substitutes the template in the block of rules you need, and the class extend takes the selector for which you apply it and substitutes it with a comma to the class .. that is:

%placeholder {
  font-weight: bold;
}
a%placeholder {
  text-decoration: none;
}
.item {
 @extend %placeholder
}

compile to
.item {
  font-weight: bold;
}
a.item {
  text-decoration: none;
}

a
.placeholder {
  font-weight: bold;
}
a.placeholder {
  text-decoration: none;
}
.item {
 @extend .placeholder
}

compile to
.placeholder, .item {
  font-weight: bold;
}
a.placeholder, a.item {
  text-decoration: none;
}

accordingly, if you apply this five times, in the first case, 5 blocks of rules will be generated for different selectors, and in the second, for one block of rules, a bunch of selectors will be added to which it is applied

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question