sass进阶—函数

/*内置函数*/

/*1)常规的rgb,rgba函数*/
$color:rgb(255,255,162);
body{
color: $color;
background-color:rgba($color, 0.5);

/*2)lighten,darken函数*/
span{
color: darken($color,0.4);//颜色加深0.4倍
background-color: lighten($color,0.5);//颜色变浅0.5倍。
}
}

 


/*str-length(),str-index() 下标是从1开始的而不是0*/
$str:'beautiful';
p{
z-index: str-length($str);
z-index: str-index($str,'f');
}

/*自定义function*/

@function double($width){
@return $width * 2;
}

a{
width: double(10px);
}


/*@warn,@debug,@error 主要用于输出*/

@debug 'this is a debug test';/*在控制台看结果*/
@warn 'warn';


/*实例:自定义一个函数,通过给定的层次,获取特定的z-index*/

转载于:https://www.cnblogs.com/LindaBlog/p/10396420.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值