sass08 if while for each
scss
@function getzIndex($layer: default){
$zindexMap: (default: 1, modal: 1000, dropdown: 500, grid: 300);
$zindex:;
@if map-has-key($zindexMap, $layer){
$zindex: map-get($zindexMap, $layer);
}
@return $zindex;
}
@debug getzIndex('afd');
//$layer可选:default,modal,dropdown,grid
$screenWidth: 500;
body{
color: if($screenWidth > 768, blue, red);//三目运算,没有@符号
}
@if $screenWidth > 768{
body{
color: red;
}
}
@else if $screenWidth >400{
span{
color: green;
}
}
@else{
p{
color: blue;
}
}
@for $i from 1 to 5{ //for语句
.span#{$i}{
width: 20% * $i;
}
}
$j: 6;
@while $j > 0{
.p#{$j}{
width: 20% * $j;
}
$j: $j - 3;
}
$k: 1;
@each $c in blue, red, green {
.div#{$k}{
color: $c; //$c是遍历的每一个值
}
$k: $k+1;
}
@each $key,$color in (default, blue), (info, green), (danger, red){
.text-#{$key}{
color: $color;
}
}
@each $key, $kk in (default: blue, info: green, danger: red){
.label-#{$key}{
color: $kk;
}
}
css
body {
color: red;
}
span {
color: green;
}
.span1 {
width: 20%;
}
.span2 {
width: 40%;
}
.span3 {
width: 60%;
}
.span4 {
width: 80%;
}
.p6 {
width: 120%;
}
.p3 {
width: 60%;
}
.div1 {
color: blue;
}
.div2 {
color: red;
}
.div3 {
color: green;
}
.text-default {
color: blue;
}
.text-info {
color: green;
}
.text-danger {
color: red;
}
.label-default {
color: blue;
}
.label-info {
color: green;
}
.label-danger {
color: red;
}
/*# sourceMappingURL=demo1.css.map */
sass08 if while for each的更多相关文章
随机推荐
- Java String.replaceAll()方法
声明 以下是java.lang.String.replaceAll()方法的声明 public String replaceAll(String regex, String replacement) ...
- PHP中对hmac_sha1签名算法的实现方法
最近研究网宿云文档API,其中用到了一种叫hmac_sha1的签名算法: HMAC-SHA1: HMAC是哈希运算消息认证码 (Hash-based Message Authentication Co ...
- hibernate之4.延迟载入
延迟载入: 仅仅有当使用以实体对象的属性(除主键属性外)时,才会发送查询语句到数据库 get不支持延迟载入 @Test public void getTest(){ Session session=n ...
- Gradle 编译多个project(包括多Library库project依赖)指导
Gradle Android最新自己主动化编译脚本教程(提供demo源代码) 这篇文章我简单写了基于Gradle2.1 进行的android project和android library的编译实例, ...
- ES shard unassigned的解决方法汇总
说下shard出现的几个状态说明: relocating_shards shows the number of shards that are currently moving from one no ...
- 4K 对齐与固态硬盘检测工具
0. 硬盘扇区 当前电脑传统机械硬盘的每个扇区一般大小为 512 字节(512B):当使用某一文件系统将硬盘格式化时,文件系统会将硬盘扇区.磁道与柱面统计整理并定义一个簇为多少扇区方便快速存储. 现时 ...
- WIN7使用VisualSVN建立SVN服务器
使用SVN开发十分的方便,这样就不用每次都拷贝粘贴来备份了,网上看到一篇给自己的windows电脑安装SVN服务器的使用非常方便. 1.下载安装文件(服务器端和客户端) 服务器端采用VisualSVN ...
- C语言学习小记
2013年1月31日 今天试着编程为报文去头去尾. #include #include #define MAX_LENTH 1024 int main() { char *path = &quo ...
- JavaScript 基础 if switch 弹窗 运算符
脚本语言最重要的几个部分: 数据类型 运算符 控制语句 数组 方法(函数) 一.基础知识 关键字:系统定义 有意义的名字如 background link 等 标识符:自己定 比如class的名字a ...
- 把阅读平台从Acrobat转到Endnote
现在阶段的学习完全到了自学,那么整理文献也必须有自己的一套思路和办法.不像硕士阶段导师给论文,而是自我指导读论文,必须有一种类似版本控制和库的快速调用的机制.而Endnote越来越必须了. 首先遇到的 ...