极品Sass简介

什么是Sass

1.世界上最成熟、最稳定、最强大的专业级CSS扩展语言
2.Sacc是一门高于CSS的语言,它能用来 清晰的、结构化地描述文件样式,有着比普通CSS更加强大的功能.
3.能够提供更简洁、更优雅的语法、同时提供多种功能来创建可维护和管理样式表
4.css预处理器

Sass的原理

Sass本质就是在CSS的语法的基础上增加了自定义的变量、循环、分支、函数、mixin、继承、运算等功能.
但是浏览器不认识Sass语法,开发者写完Sass的语法文件后需要通过工具转为Css语法

在Sass中使用变量

使用$定义变量

{}号外面定义的变量是全局变量$color:red;
$color:red;  //全局变量
a{
	$color:blue;   //花括号内定义的是局部变量
	color:$color;   //bulie
}
.bb{
	color:$color;   //red;
	
		$color:yellow !global;   //变成全局变量
		默认变量  $color:red !default;
}

Sass中的继承@extend

.btn{
	width:100px;
}

.dd{
	@extend .btn;
	height:50px;
}

Sass中的引入@import

如 _aa.scss


@charset="utf-8";
*{
	padding:0px;
	margin:0px;
}

b.scss引入_aa.scss文件

@import "_aa"

Sass中的函数

$colors:(red:red,light:white,dark:black);
@function color($key){
	@if not map-has-key($colors,$key){
		@warn "警告,gulp不会终端"
		@error "会终止监听"
	}
	@return map-get($colors,$key);
}
//函数调用
body{
	background-color:color(red);
}


Sass中的控制指令

$a = red;
.box{
	@if $a == red{

	}@else if $a ==blue{
		
	}@else{

	}
}

Sass中的循环

@for
$count: 12;
//包含结束位置
@for $i from 1 through $count{
    li:nth-child(#{$i}){
        width: 100px / 12 * $i;
    }
}

//不包含结束位置
@for $i from 1 to $count{
    li:nth-child(#{$i}){
        width: 100px / 12 * $i;
    }
}

Sass中的@each

$icons: success warning error primary info;
@each $icon in $icons{
    #box li:nth-child(#{$icon}){
        background: url(images/#{$icon}.png) no-repeat;
    }
}

Sass中的@while

$i : 6;
@while $i > 0 {
    li:nth-child(#{$i}){
        font-size: #{$i*16}px;
    }
     $i : $i - 1;
}

这里就是我的简介

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值