SASS常用樣式總結(jié)

關(guān)于媒體查詢

// 媒體查詢
$media-stack:
(group: tablet, id: general, rule: "only screen and (max-width: 768px)"),
(group: desktop, id: general, rule: "only screen and(min-width: 769px) and (max-width: 1023px)"),
(group: smaller, id: general, rule: "only screen and(min-width: 1024px) and (max-width: 1169px)"),
(group: large, id: general, rule: "only screen and (min-width: 1170px)"),
(group: print, id: general, rule: "only print");

@mixin media($group, $id: general){  //引用:@include media(tablet){具體樣式}
@each $media in $media-stack{
  @if($group == map-get($media, group) and $id == map-get($media, id)){
      $rule: map-get($media, rule);
      @media #{$rule} {@content}
    }
  }
}

關(guān)于flex布局

//flex布局
@mixin flex-box{
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-box;  
  display: -ms-flex;
  display: flex;
}
@mixin flex-1($percent){
  width:$percent;
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  -moz-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
}
@mixin justify-content{
  -webkit-justify-content:space-between;
  justify-content:space-between;
}

關(guān)于動畫

//關(guān)于動畫
@mixin transition($transition) {
  -moz-transition: $transition;
  -webkit-transition: $transition;
  -ms-transition: $transition;
  -o-transition: $transition;
  transition: $transition;
}
@mixin transform-origin($origin) {
    -moz-transform-origin:$origin;
    -webkit-transform-origin:$origin;
    -ms-transform-origin:$origin;
    -o-transform-origin:$origin;
    transform-origin:$origin;
}
@mixin scale($scale) {
    -moz-transform:scale($scale);
    -webkit-transform:scale($scale);
    -ms-transform:scale($scale);
    -o-transform:scale($scale);
    transform:scale($scale);
}

透明度

//透明度
@mixin opacity($opacity) {
  opacity: $opacity;
  filter: alpha(opacity=$opacity * 100);//兼容IE
}

超出的文本省略

//超出一行文本省略
@mixin overflow() {
  overflow: hidden;
  -ms-text-overflow: ellipsis;
  text-overflow: ellipsis;
  white-space: nowrap;
}
//多行超出文本省略
@mixin overflow-more($num) {
  display:-webkit-box; 
  -webkit-box-orient:vertical;
  -webkit-line-clamp:$num;
  display: -moz-box; 
  -moz-line-clamp: $num !important;
  -moz-box-orient: vertical;
  overflow: hidden;
}

圓角

// 圓角
@mixin border-radius($radius) {
  -webkit-border-radius:$radius;
  -moz-border-radius:$radius;
  -o-border-radius:$radius;
  border-radius:$radius;
}

陰影

// 設(shè)置陰影
@mixin box-shadow($shadow...) {
  -webkit-box-shadow:$shadow;
  -moz-box-shadow:$shadow;
  -o-box-shadow:$shadow;
  box-shadow:$shadow;
}

居中

// 絕對居中
@mixin center($width, $height) {
  position: absolute;
  left:50%;
  top:50%;
  width:$width;
  height:$height;
  margin:(-$height / 2) 0 0 (-$width / 2);
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 選擇qi:是表達(dá)式 標(biāo)簽選擇器 類選擇器 屬性選擇器 繼承屬性: color,font,text-align,li...
    wzhiq896閱讀 2,138評論 0 2
  • 選擇qi:是表達(dá)式 標(biāo)簽選擇器 類選擇器 屬性選擇器 繼承屬性: color,font,text-align,li...
    love2013閱讀 2,460評論 0 11
  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,374評論 25 708
  • View屬性小結(jié) 待改進(jìn) 標(biāo)識類屬性 android:id:Supply an identifier name f...
    Passon_Fang閱讀 2,295評論 0 0
  • 今天看到一則新聞,四川夫妻生下了11孩子,起初我并不覺得奇怪,在小時候聽奶奶講,她們那個時代總是生下很多孩子,表示...
    云由故理閱讀 314評論 2 1

友情鏈接更多精彩內(nèi)容