我的mixin.scss文件

@mixin text-ellipsis() {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@mixin text-ellipsis-multi($line) {
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: $line;
  -webkit-box-orient: vertical;
}

@mixin flex-center($direction: row) {
  display: flex;
  flex-direction: $direction;
  align-items: center;
  justify-content: center;
}

@mixin box-shadow {
  box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.2);
}

@mixin img-wrap($width, $height: $width) {
  width: $width;
  height: $height;
  flex-shrink: 0;

  img {
    width: 100%;
    height: 100%;
  }
}

@mixin abs-stretch {
  position: absolute;
  left: 0;
  bottom: 0;
  top: 0;
  right: 0;
}

@mixin abs-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

@mixin round($d) {
  width: $d;
  height: $d;
  border-radius: 50%;
}

@mixin list($item-width) {
  .list-wrap {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -12px;

    .list-item {
      width: $item-width;
      margin-bottom: 36px;
      padding: 0 12px;
    }
  }
}

// 定位
@mixin dw($position, $top, $left) {
  position: $position;
  top: $top;
  left: $left;
}

// 宽高100%
@mixin full_wh {
  width: 100%;
  height: 100%;
}

//宽高
@mixin wh($width, $height) {
  width: $width;
  height: $height;
}

// 宽高一样
@mixin same-wh($length) {
  width: $length;
  height: $length;
}

// 转行内块  宽高
@mixin inbwh($width, $height) {
  display: inline-block;
  width: $width;
  height: $height;
}

// 行高垂直居中 tac水平居中
@mixin lhtac($lineheight, $center: center) {
  line-height: $lineheight;
  text-align: $center;
}

// 背景图片地址和大小
@mixin bgi($url) {
  background-image: url($url);
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

@mixin borderRadius($radius) {
  -webkit-border-radius: $radius;
  -moz-border-radius: $radius;
  -ms-border-radius: $radius;
  -o-border-radius: $radius;
  border-radius: $radius;
}

//定位上下左右居中
@mixin center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

//定位上下居中
@mixin ct {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

//定位左右居中
@mixin cl {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

// 字体和颜色
@mixin fc($size, $color) {
  font-size: $size;
  color: $color;
}

// 字体颜色行高
@mixin fclh($size, $color, $lh) {
  font-size: $size;
  color: $color;
  line-height: $lh;
}

// flex布局
@mixin flex($buju: space-between) {
  display: flex;
  justify-content: $buju;
}

 

posted @ 2020-06-11 15:54  haha-uu  阅读(237)  评论(0编辑  收藏  举报