Answers for "using media queries in scss"

CSS
4

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;
}
Posted by: Guest on February-21-2021
1

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;
        }
      }
    }
Posted by: Guest on October-24-2020

Browse Popular Code Answers by Language