scss 方便的sass mixin用于媒体查询

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了scss 方便的sass mixin用于媒体查询相关的知识,希望对你有一定的参考价值。

$break-small: 320px;
$break-large: 1024px;

 @mixin  respond-to($media) {
   @if  $media == handhelds {
     @media  only screen and (max-width: $break-small) { @content; }
  }
   @else  if $media == medium-screens {
     @media only screen and (min-width: $break-small + 1) and (max-width: $break-large - 1) { @content; }
  }
   @else  if $media == wide-screens {
     @media only screen and (min-width: $break-large) { @content; }
  }
   @else  if $media == retina-screens {
     @media  only screen and (min-width: $break-small + 1) and (max-width: $break-large - 1) and (min-device-pixel-ratio: 1.5) and (-webkit-min-device-pixel-ratio: 1.5) { @content; }
  }
}

.profile-pic {
  float: left;
  width: 250px;
  @include  respond-to(handhelds) { width: 100% ;}
  @include  respond-to(medium-screens) { width: 125px; }
  @include  respond-to(wide-screens) { float: none; }
  @include  respond-to(retina-screens) {background-image:url()}
}

以上是关于scss 方便的sass mixin用于媒体查询的主要内容,如果未能解决你的问题,请参考以下文章

scss 自定义Sass mixin用于使用媒体查询

scss Vanilla CSS媒体查询+ Sass媒体查询mixin

scss 简单的媒体查询Sass mixin可以让你考虑像素宽度,但输出是在ems中。

scss 用于响应媒体查询的Mixins

scss 更方便的sass mixins

scss 更方便的sass mixins