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的更多相关文章
随机推荐
- HDOJ 2189 悼念512汶川大地震遇难同胞——来生一起走 【母函数】
题意:非常清楚不解释. 策略:如题. 就是个简单的母函数的改变. 这道题做了好久,才明确是那有毛病,还是理解的不够深刻. AC代码: #include<stdio.h> #include& ...
- 138.安全退出的异常,要用throw 尽量不用exit(0)
#include<iostream> #include<cstdlib> using namespace std; ////非安全退出,结束进程, //C++ 必须释放对象,最 ...
- POJ 2188线段树求逆序对
题目给的输入是大坑,算法倒是很简单-- 输入的是绳子的编号wire ID,而不是上(或下)挂钩对应下(或上)挂钩的编号. 所以要转换编号,转换成挂钩的顺序,然后再求逆序数. 知道了这个以后直接乱搞就可 ...
- Django(part2)
admin site:django自带了admin site,我们需要创建能访问site的用户 #以交互的方式创建超级用户 manage.py createsuperuser 如果要把model加到a ...
- Ubuntu PPA 使用指南
作者: Abhishek Prakash 译者: LCTT jlztan | 2019-01-19 11:02 一篇涵盖了在 Ubuntu 和其他 Linux 发行版中使用 PPA 的几乎所有问题的深 ...
- li自定义图标
/*自定义list的图标*/ li{ list-style-image: url(../img/21.JPG); }
- sql 技巧
1.想把一张表的 某个字段或多个字段 的 所有数据 复制到另外一张表里 insert into 表名(字段) select (字段) from 表名 2.from Users u , IN(u.ro ...
- 【PRML学习笔记】第四章:分类的线性模型
一.基础概念 线性分类模型:决策面(decision boundary)是输入向量的线性函数 目标类别的表示"1 of K" :$ t = (0,1,0,0,0)^T$ 二.分类问 ...
- solr启动时报错org.apache.solr.common.SolrException: undefined field text的解决办法
solr启动时报错org.apache.solr.common.SolrException: undefined field text的解决办法 原创 2015年08月21日 20:47:40 标签: ...
- 洛谷—— P2701 [USACO5.3]巨大的牛棚Big Barn
https://www.luogu.org/problem/show?pid=2701 题目背景 (USACO 5.3.4) 题目描述 农夫约翰想要在他的正方形农场上建造一座正方形大牛棚.他讨厌在他的 ...