sass media query mixins code example
Example 1: scss media query
$information-phone: "only screen and (max-width : 320px)";
@media #{$information-phone} {
background: red;
}
Example 2: sass mixin
@mixin transform($property) {
-webkit-transform: $property;
-ms-transform: $property;
transform: $property;
}
.box { @include transform(rotate(30deg)); }
Example 3: Sass @mixin and @include
@mixin important-text {
color: red;
font-size: 25px;
font-weight: bold;
border: 1px solid blue;
}
Example 4: media screen scss mixin
// respond is the name of your mixin
@mixin respond ($breakpoint) {
// $breakpoint is simply a variable that can have several values
@if $breakpoint==tablet {
// here `laptop` is the value of $breakpoint
// when call laptop, we mean the following piece of code
@media only screen and (max-width: 600px) {
@content;
}
}
@if $breakpoint==mobile {
@media only screen and (max-width: 480px) {
@content;
}
}
}