• scss 常用的函数总结。


    /*

    • px2rem 转换
      /
      (base-font-size: 750; @function px2rem()px) {
      @return (px / 75px * 1rem; } @function rem()px) {
      @return ($px / (base-font-size) * 10rem; } @function vw()px) {
      @return ($px / $base-font-size) * 100vw;
      }
      /
    • methods
      */
      // 定位上下左右居中
      @mixin pcenter {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      }

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

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

    // 字体大小,颜色
    @mixin fsc($size, (color) { font-size: px2rem()size);
    color: $color;
    }

    // flex 布局和子元素对齐方式
    @mixin flex($type: space-between) {
    display: flex;
    justify-content: (type; } @mixin wh()width, $height) {
    $width;
    height: (height; } @mixin square()size) {
    @include wh($size, (size); } @mixin size()width, $height) {
    $width;
    height: (height; } @mixin text_overflow()lines: 1) {
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-line-clamp: $lines;
    -moz-line-clamp: $lines;
    -webkit-box-orient: vertical;
    -moz-box-orient: vertical;
    @if (lines == 1 { white-space: nowrap; display: block; } @else { display: -webkit-box; } } @mixin overflow-line()lines) {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    /*! autoprefixer: ignore next */
    -webkit-box-orient: vertical;
    -webkit-line-clamp: $lines;
    -moz-line-clamp: (lines; } @mixin text-overflow()lines: 1) {
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-line-clamp: $lines;
    -moz-line-clamp: $lines;
    -webkit-box-orient: vertical;
    -moz-box-orient: vertical;
    @if $lines == 1 {
    white-space: nowrap;
    display: block;
    } @else {
    display: -webkit-box;
    }
    }
    @mixin overflow_auto {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    }

    @mixin box-sizing($sizing: border-box) {
    -webkit-box-sizing: $sizing;
    -moz-box-sizing: $sizing;
    box-sizing: (sizing; } @mixin sc()size, $color) {
    font-size: $size;
    color: $color;
    }
    @mixin clearfix {
    &:before,
    &:after {
    content: ' ';
    display: table;
    }
    &:after {
    clear: both;
    }
    }
    @mixin iphoneX-footer() {
    [data-dpr='2'] & {
    @media only screen and (device- 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) {
    //iphoneXR
    padding-bottom: calc(env(safe-area-inset-bottom) * 2);
    }
    }

    [data-dpr='3'] & {
    @media only screen and (-webkit-device-pixel-ratio: 3) {
    //iphone X Xs XsMax
    padding-bottom: calc(env(safe-area-inset-bottom) * 3);
    }
    }
    }

  • 相关阅读:
    可变形参 Day07
    流程控制 Day06
    基本数据类型的值传递 和引用数据类型的引用传递 Day06
    一维数组的求平均成绩 Day06
    一维数组的初始化及遍历 Day06
    字符串分割+二维数组 Day15练习
    Java对数组和列表的排序1.8新特性
    Java Stream
    JPA学习(六、JPA_JPQL)
    JPA学习(五、JPA_二级缓存)
  • 原文地址:https://www.cnblogs.com/pansidong/p/13737671.html
Copyright © 2020-2023  润新知