What is the meaning of the "@include" in .css Files?
Asked Answered
E

2

25

I don't understand , what is the meaning of the @include tag in .css files. For Example :

.wrapper {
display: flex;
width: 100%;
@include display(flex);
@include flex-direction(column);
@include align-items(center);
@include justify-content(center);
@include transition(all 2s linear);
}
Elburt answered 3/9, 2016 at 22:8 Comment(0)
B
40

@includes are a part of SCSS, it's called Mixin. Here is an example:

@mixin border-radius($radius) {
    -webkit-border-radius: $radius;
       -moz-border-radius: $radius;
        -ms-border-radius: $radius;
            border-radius: $radius;
}

.box { @include border-radius(10px); }

@includes are a shortcut to storing especially things like vendor prefixes. The CSS output of the above will be:

.box {
    -webkit-border-radius: 10px;
       -moz-border-radius: 10px;
        -ms-border-radius: 10px;
            border-radius: 10px;
}
Bennink answered 3/9, 2016 at 22:17 Comment(0)
K
0

Just like you have reusable function in JavaScript, maxins allow you to have reuseable css declarations in a .scss file. more about scss here. The @include tells scss to use the declaration provided. Here is an example below.

SCSS CODE

enter image description here

CSS output

enter image description here

Knell answered 4/4 at 17:0 Comment(1)
Please read Why should I not upload images of code/data/errors?Villainy

© 2022 - 2024 — McMap. All rights reserved.