博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sass 的学习
阅读量:7027 次
发布时间:2019-06-28

本文共 2494 字,大约阅读时间需要 8 分钟。

导入scss

@import "../../sass/variables.scss";@import "../../sass/helper.scss";

 

@mixin

@mixin flex ($a, $b) {    display: flex;    justify-content: $a;    align-items: $b;}

使用:@include flex(flex-start, center);

 

@function

$base-font-size: 75px;@function pxToRem($px) {    @return  $px / $base-font-size * 1rem;}

使用: font-size: pxToRem(50px);

 

@if

@mixin position ($top, $right, $bottom, $left) {    position: absolute;    @if $top {          top: $top;     }    @if $right {         right: $right;    }    @if $bottom {        bottom: $bottom;    }    @if $left {        left: $left;    }}

@include position(false,false,30rpx, 30rpx);

 

@if or / and

@mixin flex ($x: false, $y: false, $direction: false) {
display: flex; @if $x { @if $x == s or $x == start { justify-content: flex-start; } @else if $x == c or $x == center {
justify-content: center; } @else if $x == e or $x == end {
justify-content: flex-end; } @else if $x == a or $x == around {
justify-content: space-around; } @else if $x == b or $x == between {
justify-content: space-between; } @else {
justify-content: $x; } } @if $y {
@if $y == s or $y == start { align-items: flex-start; } @else if $y == c or $y == center {
align-items: center; } @else if $y == e or $y == end {
align-items: flex-end; } @else if $y == stretch or $y == full or $y == f {
align-items: stretch; } @else if $y == baseline or $y == base or $y == b or $y == line or $y == l {
align-items: baseline; } @else {
align-items: $y; } } @if $direction {
flex-direction: $direction; }}

 

 

默认参数

@mixin flex ($a: false, $b: false, $c:false) {    display: flex;    @if $a {        justify-content: $a;    }    @if $b {        align-items: $b;    }    @if $c {        flex-direction: $c;    }}

 

 @for 循环

 

@for $i from 1 through 5 {   $em: if($i == 1, $i/2, $i - 1) + em;   .u-m-#{$i}{margin: #{$em}}   .u-mt-#{$i}{margin-top: #{$em}}   .u-mr-#{$i}{margin-right: #{$em}}   .u-mb-#{$i}{margin-bottom: #{$em}}   .u-ml-#{$i}{margin-left: #{$em}}   .u-pt#{i}{padding: #{$em}}   .u-pt-#{$i}{padding-top: #{$em}}   .u-pr-#{$i}{padding-right: #{$em}}   .u-pb-#{$i}{padding-bottom: #{$em}}   .u-pl-#{$i}{padding-left: #{$em}}}

 

 

转载于:https://www.cnblogs.com/CyLee/p/8506091.html

你可能感兴趣的文章
2012年4月MVP申请截止时间:2012年1月12日
查看>>
mydns的安装
查看>>
tar增量备份
查看>>
xen 故障汇总
查看>>
SecureCRT的使用--增加队列
查看>>
搭建gitlab
查看>>
linux常用命令-cd/type/printenv/hash
查看>>
python第二章 变量
查看>>
数据中心虚拟化需要大二层网络
查看>>
在Exchange server 2007中管理pop3和IMAP4协议访问
查看>>
后台在线编辑模板禁止提交含有{php 的标签解决办法
查看>>
《iPhone与iPad开发实战—iOS经典应用剖析》连载二
查看>>
软raid的详细配置讲解 raid 1
查看>>
js中通用的Object属性和方法
查看>>
如何在App中实现IM功能之六快速实现群聊的高级功能——箭扣科技Arrownock
查看>>
dig一些常用例子
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
MYCAT分布式MYSQL中间件(数据库切分概述)[转]
查看>>
安装MySQL-python报错
查看>>