Answer the question
In order to leave comments, you need to log in
Does this use of mixin have the right to life?
Hello, there is a _mixin.scss file with the code:
@mixin flex {
display: flex;
}
@mixin align-center {
align-items: center;
}
@mixin column {
flex-direction: column;
}
и т.д.
.header {
@include flex;
}
.content {
@include flex;
@include column;
@include align-center;
}
.footer {
@include flex;
}
Answer the question
In order to leave comments, you need to log in
Also, this might make sense:
@mixin flex($align: null, $direction: null) {
display: flex;
@if $align {
align-items: $align;
}
@if $direction {
flex-direction: $direction;
}
}
.header {
@include flex;
}
.content {
@include flex(center, column);
}
.footer {
@include flex;
}
I don’t see the point in this, you replace everything with the same, only with a slightly different design.
Of course it has. However, the point of Using Mixes is to optimize a certain rule to use the "Short" approach to writing styles, mainly not even for convenience, but to increase the speed of layout. So the answer is "Yes" but in this case, in your example, you are changing the awl to soap :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question