write media query in sass code example

Example 1: media query in scss

$media-desktop: "only screen and (max-width : 1024px)";
$media-tablet: "only screen and (max-width : 768px)";
$media-mobile: "only screen and (max-width : 600px)";
$media-mobile-sm: "only screen and (max-width : 480px)";


@media #{$media-desktop} {
  background: red;
}

@media #{$media-tablet} {
  background: red;
}

@media #{$media-mobile} {
  background: red;
}

@media #{$media-mobile-sm} {
  background: red;
}

Example 2: media queries scss

$media-desktop: "only screen and (max-width : 1024px)";
$media-tablet: "only screen and (max-width : 768px)";
$media-mobile: "only screen and (max-width : 600px)";
$media-mobile-sm: "only screen and (max-width : 480px)";


@media #{$media-desktop} {
  background: red;
}

@media #{$media-tablet} {
  background: red;
}

@media #{$media-mobile} {
  background: red;
}

@media #{$media-mobile-sm} {
  background: red;
}

Tags:

Css Example