导入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  through  {
$em: if($i == , $i/, $i - ) + 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}}
}

sass 的学习的更多相关文章

  1. sass入门学习篇(一)

    先简单的介绍一下sass,如果你了解less,sass就没什么太大问题 Sass 是对 CSS 的扩展,让 CSS 语言更强大.优雅. 它允许你使用变量.嵌套规则. mixins.导入等众多功能, 并 ...

  2. sass个人学习笔记

    Materliu 在慕课的视频: http://www.imooc.com/learn/364 . http://www.imooc.com/wiki/371 sass入门:http://www.w3 ...

  3. sass基础学习(一)

    移动端布局各种问题 pc端布局各种问题sass 组件模块化面向对象编程ajax 框架学习 webpack 打包 性能优化 gulp是基于Nodejs的自动任务运行器她能自动化地完成 javascrip ...

  4. sass的学习笔记

    sass初学入门笔记(一) 我本身是个新手,一边学sass一边记下的笔记,可能有点罗嗦,但是复习起来的话还是比较全面直观的.当然,最重要的还是去实践,实践得真理 其它 CSS 预处理器语言: CSS ...

  5. sass,compass学习笔记总结

    最近在进行百度前端技术学院的任务,知道自己基础薄弱,可没想到弱到这种地步,同时在安装各种软件的同时遇到了各种坑,查阅了各种资料,一个个解决的时候也发现自己凌乱了.学习总结,在脑海中形成自己的学习系统才 ...

  6. Sass的学习

    第一章:Sass简介 一. 什么是CSS预处理器 定义:CSS预处理器定义了一种新的语言,其基本思想是,用一种专门的编程语言,为CSS增加一些编程的特性,将CSS作为目标生成文件,然后开发者就只要使用 ...

  7. Sass&Compass学习笔记(一)

    1.sass中可以使用变量 变量名以$符号开头,可包含所有可用作CSS类名的字符,包括下划线和中划线. 可见,中划线也是可以作为命名的字符,这是与很多其他语言的不同之处.变量的使用实例: $compa ...

  8. sass基础学习

    2015.6.281.安装ruby2.运行gem安装sass-->gem install sass3.编译命令行sass --watch 文件路径/test.scss:编译后文件路径/test. ...

  9. sass入门学习篇(二)

    从语法开始但是语法也不是一两句的事情,首先看基本的导入,使用 一,sass有两种后缀名文件:一种后缀名为sass,不使用大括号和分号:另一种就是我们这里使用的scss文件,建议scss. 二,导入 使 ...

随机推荐

  1. JAVA EE 中之AJAX 无刷新地区下拉列表三级联动

    JSP页面 <html> <head> <meta http-equiv="Content-Type" content="text/html ...

  2. HDU 4578 Transformation (线段树)

    Transformation Time Limit: 15000/8000 MS (Java/Others)    Memory Limit: 65535/65536 K (Java/Others)T ...

  3. java8 遍历数组的几种方式

    java8 遍历数组的几种方式 2017年04月05日 09:15:46 阅读数:4640 风格色 2017-02-11 18:41 有如下一个String数组 String[] array = {& ...

  4. ylbtech-LanguageSamples-Libraries(库)

    ylbtech-Microsoft-CSharpSamples:ylbtech-LanguageSamples-Libraries(库) 1.A,示例(Sample) 返回顶部 “库”示例 本示例演示 ...

  5. iOS:第三方框架MJPhotoBrowser图片浏览器的使用

    介绍:MJPhotoBrowser这个第三方库是MJ老师封装的一套用来浏览图片的浏览器,可是是本地图片.网络图片.gif图片等,其也依赖了SDWebImage.SVProgressHUD.YLGIFI ...

  6. yaha分词

    yaha分词:https://github.com/jannson/yaha

  7. hdoj-1301-Jungle Roads【最小生成树】

    Jungle Roads Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...

  8. git中报unable to auto-detect email address

    git commit 时报错: ** Please tell me who you are. Run git config --global user.email "you@example. ...

  9. [CSS3] Make a One-time CSS Animation that Does Not Revert to its Original Style

    We'll add animation to patio11bot using CSS keyframes. When defining a CSS animation, you can add it ...

  10. apache无法启动:The request operation has failed

    apache无法启动提示the requested operation has failed 的错误信息,有以下几种解决方法:1.80端口占用 apache默认使用的端口是80,而IIS和迅雷用的也是 ...