@mixin safe-area($attr:height, $val:0px, $direction:top) {
    $top-constant: calc(#{$val} + constant(safe-area-inset-top)); // 兼容 iOS < 11.2
    $top-env: calc(#{$val} + env(safe-area-inset-top)); // 兼容 iOS >= 11.2
    $bottom-constant: calc(#{$val} + constant(safe-area-inset-bottom)); // 兼容 iOS < 11.2
    $bottom-env: calc(#{$val} + env(safe-area-inset-bottom)); // 兼容 iOS >= 11.2

    @if $attr==height {
        height: $val;

        @if $direction==top {
            height: $top-constant;
            height: $top-env;
        }

        @else if $direction==bottom {
            height: $bottom-constant;
            height: $bottom-env;
        }
    }

    @if $attr==padding {
        @if $direction==top {
            padding-top: $val;
            padding-top: $top-constant;
            padding-top: $top-env;
        }

        @else if $direction==bottom {
            padding-bottom: $val;
            padding-bottom: $bottom-constant;
            padding-bottom: $bottom-env;
        }
    }

    @if $attr==position {
        @if $direction==top {
            top: $val;
            top: $top-constant;
            top: $top-env;
        }

        @else if $direction==bottom {
            bottom: $val;
            bottom: $bottom-constant;
            bottom: $bottom-env;
        }
    }
}

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

// 超过多少行问诊显示省略号
@mixin _cut($num) {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: $num;
    -webkit-box-orient: vertical;
}

@mixin _word() {
    text-align: justify;
    text-justify: newspaper;
    word-break: break-all;
}

// 局部滚动
@mixin scroll() {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

@function px2rem($x) {
    // @return $x / 37.5 * 1rem;
    @return calc($x / 37.5) * 1rem;
}

@mixin flexcenter {
    display: flex;
    align-items: center;
    justify-content: center;
}

@mixin wh100 {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
}