mixins.scss 3.7 KB
// 居中按钮样式
@mixin btn-center($width, $height) {
  width: $width;
  height: $height;
  line-height: $height;
  text-align: center;
}

// 超过多少行自动省略 默认一行
@mixin ellipsis($line: 1) {
  display: -webkit-box;
  word-break: break-all;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: $line;
  overflow: hidden;
  text-overflow: ellipsis;

  -ms-text-overflow: ellipsis;
}
@mixin ellipsis1() {
  display: -webkit-box;
  word-break: break-all;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

// 文字截取
@mixin text-overflow() {
  overflow: hidden;
  white-space: normal;
  text-overflow: ellipsis;
  word-break: break-all;
  word-wrap: normal;
}

@mixin word-break() {
  word-break: break-all;
  word-wrap: break-word;
  white-space: normal;
}

// No wrap
@mixin no-wrap() {
  word-break: normal;
  word-wrap: normal;
  white-space: nowrap;
}

// 清除浮动
@mixin clearfix() {
  &:before,
  &:after {
    content: " "; // 1
    display: table; // 2
  }

  &:after {
    clear: both;
  }
}

// Single side border-radius
@mixin border-top-radius($radius) {
  border-top-right-radius: $radius;
  border-top-left-radius: $radius;
}

@mixin border-right-radius($radius) {
  border-bottom-right-radius: $radius;
  border-top-right-radius: $radius;
}

@mixin border-bottom-radius($radius) {
  border-bottom-right-radius: $radius;
  border-bottom-left-radius: $radius;
}

@mixin border-left-radius($radius) {
  border-bottom-left-radius: $radius;
  border-top-left-radius: $radius;
}

// Center-align a block level element
@mixin center-block() {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

// CSS image replacement
// Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757
@mixin hide-text() {
  font-size: 0;
  line-height: 0;
  color: transparent;
  text-shadow: none;
  background-color: transparent;
  border: 0;
}

// 橙色底实心 自定义圆角按钮
@mixin btc($hei: 22px, $borderRadius: 4px, $padding: 12px, $fontSize: 14px) {
  @extend .fcc;
  padding: 0 $padding;
  height: $hei;
  line-height: normal;
  text-align: center;
  border-radius: $borderRadius;
  background-color: $cOrange;
  font-size: $fontSize;
  color: #ffffff;
  letter-spacing: 1.4px;
  cursor: pointer;
  user-select: none;
}

// 白底空心 自定义圆角按钮
@mixin btc-o($hei: 22px, $borderRadius: 4px, $padding: 12px, $fontSize: 14px) {
  @extend .fcc;
  @extend .bb;
  padding: 0 $padding;
  height: $hei;
  line-height: normal;
  text-align: center;
  border-radius: $borderRadius;
  font-size: $fontSize;
  color: $cOrange;
  letter-spacing: 1.4px;
  background-color: #ffffff;
  cursor: pointer;
  border: solid 1px $cOrange;
  user-select: none;
}

// 定宽 橙色底实心圆角按钮
@mixin btc2($wid: 118px, $hei: 22px, $fontSize: 14px) {
  width: $wid;
  height: $hei;
  line-height: $hei + 2px;
  text-align: center;
  border-radius: $hei * 0.5;
  background-color: $cOrange;
  font-size: $fontSize;
  color: #ffffff;
  letter-spacing: 1.4px;
  cursor: pointer;
  user-select: none;
}

// 橙框橙字
@mixin btc3($hei: 22px, $fontSize: 14px) {
  height: $hei;
  line-height: $hei;
  padding: 0 12px;
  text-align: center;
  border-radius: 2px;
  font-size: $fontSize;
  letter-spacing: 1.4px;
  cursor: pointer;
  user-select: none;
  color: $cOrange;
  border: solid 1px $cOrange;
}

// 定宽 黑色底实心圆角按钮
@mixin btc4($wid: 118px, $hei: 22px, $fontSize: 14px) {
  width: $wid;
  height: $hei;
  line-height: $hei + 2px;
  text-align: center;
  border-radius: $hei * 0.5;
  background-color: $cLightDard;
  font-size: $fontSize;
  color: #ffffff;
  letter-spacing: 1.4px;
  cursor: pointer;
  user-select: none;
}