![]() |
VOOZH | about |
Mixin is one of the best features of SASS, which works like a function. You can create mixins for repeated CSS properties and then include those mixins using @include in your CSS class.
Approach:SASS file: The following code snippet demonstrates the SASS file with the extension ".scss".
@mixin placeholder
{
&::-webkit-input-placeholder {@content}
&:-moz-placeholder {@content}
&::-moz-placeholder {@content}
&:-ms-input-placeholder {@content}
}
input {
@include placeholder {
font-family: robota;
font-size: 20px;
color: red;
font-style: italic;
}
}
Place the above SASS code in "style.scss" file and use the below command to create "style.css" file from the SASS file. The command will only work if you have SASS installed in your system. You can download it from the official website of SASS.
sass style.scss style.css
This will create the "style.css" file in your working directory. The working directory will hold files which are "index.html","style.scss" and "style.css".
CSS code: The following code is the outcome of the above SASS file which when executed is converted to "style.css" file .
input::-webkit-input-placeholder {
font-family: robota;
font-size: 20px;
color: red;
font-style: italic;
}
input:-moz-placeholder {
font-family: robota;
font-size: 20px;
color: red;
font-style: italic;
}
input::-moz-placeholder {
font-family: robota;
font-size: 20px;
color: red;
font-style: italic;
}
input:-ms-input-placeholder {
font-family: robota;
font-size: 20px;
color: red;
font-style: italic;
}
HTML code: The following code demonstrates the "index.html" file.
Output:
👁 Image