常用的scss工具方法封装

主要总结开发中常用的工具方法:

1.移动端1px

@mixin border1($bColor,$type:bottom){
  position: relative;
  &::before{
    content:'';
    display: block;
    position: absolute;
    left:0;
    right: 0;
    @if ($type == 'top'){
      top: 0;
    }
    @if ($type == 'bottom'){
      bottom: 0;
    }
    border-#{$type}: 1px solid $bColor;
    transform: scaleY(0.5);
  }
}

2.宽高的设定

@mixin wh($w,$h:$w){
  width: $w;
  height: $h;
  min-width: $w;
}

3.ios手机的安全区域适配

//iPhone X、iPhone XR、iPhone XS Max、iPhone 11、iPhone 11 Pro、iPhone 11 Pro Max适配	
@mixin ipAdaptive($name:'p',$n:''){
  @if ($name == 'p'){
		padding-bottom: calc(#{$n} +  constant(safe-area-inset-bottom)); /*兼容 IOS<11.2*/
    padding-bottom: calc(#{$n} +  env(safe-area-inset-bottom)); /*兼容 IOS>11.2*/
  }
  @else if($name == "m"){
		/* 可以通过margin-bottom来适配 */
		margin-bottom: calc(#{$n} +  constant(safe-area-inset-bottom));
		margin-bottom: calc(#{$n} +  env(safe-area-inset-bottom));
	}
	@else if($name == "h"){
		/* 或者改变高度*/
		height: calc(#{$n} +  constant(safe-area-inset-bottom));
		height: calc(#{$n} +  env(safe-area-inset-bottom));
	}
}

4.单行省略号

@mixin unline {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: no-wrap;
}

5.多行省略

@mixin ellipsis($row:1){
  display: -webkit-box;     /* WebKit内核浏览器支持 */
  -webkit-line-clamp: $row;    /* 限制显示的行数 */
  -webkit-box-orient: vertical; /* 垂直方向展示 */
  overflow: hidden;          /* 超出部分隐藏 */
  text-overflow: ellipsis;   /* 显示省略号 */
}

相关推荐

  1. 常用scss工具方法封装

    2024-04-04 10:24:01       34 阅读
  2. SCSSSass区别?

    2024-04-04 10:24:01       29 阅读
  3. 【5种常见rpc封装方案

    2024-04-04 10:24:01       50 阅读
  4. CSS、less、SassScss、Stylus认识

    2024-04-04 10:24:01       43 阅读
  5. 探索Sass:Web开发强大工具

    2024-04-04 10:24:01       28 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-04 10:24:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-04 10:24:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-04-04 10:24:01       82 阅读
  4. Python语言-面向对象

    2024-04-04 10:24:01       91 阅读

热门阅读

  1. ubuntu thrift 编译和使用

    2024-04-04 10:24:01       33 阅读
  2. MFC 获取程序版本信息

    2024-04-04 10:24:01       40 阅读
  3. SAM Self-Attention based Deep Learning Method

    2024-04-04 10:24:01       37 阅读
  4. React|获取oss存储的文件,并转为json格式

    2024-04-04 10:24:01       38 阅读
  5. CV最新论文|4月1日 arXiv更新论文合集

    2024-04-04 10:24:01       35 阅读
  6. Spring和SpringBoot的区别

    2024-04-04 10:24:01       40 阅读
  7. Gin框架(3)

    2024-04-04 10:24:01       31 阅读
  8. Qt之QSoundEffect播放简单音效

    2024-04-04 10:24:01       27 阅读
  9. NLP学习路线指南总结

    2024-04-04 10:24:01       36 阅读