[SCSS] Convert SCSS Variable Arguments to JavaScript
We will learn how to convert variable arguments by using rest operator in JavaScript.
.sass-btn {
color: #fff;
background-color: #0069d9;
margin: 5px;
@include button-size();
@include box-shadow(0px 4px 5px #, 2px 6px 10px #);
}
@mixin box-shadow($shadows...) {
-moz-box-shadow: $shadows;
-webkit-box-shadow: $shadows;
box-shadow: $shadows;
}
Scss "$shadows..." the same as "...shadows" in Javascript.
export const boxShadow = (...shadows) => `
-moz-box-shadow: ${shadows};
-webkit-box-shadow: ${shadows};
box-shadow: ${shadows};
`
interesting thing is ...shadows in Javascript is an Array, but if we put into ${}, then it conver to a string:
const shadows = ['red', 'blue'];
console.log(`${shadows}`); // red, blue
[SCSS] Convert SCSS Variable Arguments to JavaScript的更多相关文章
- convert image to base64 in javascript
convert image to base64 in javascript "use strict"; /** * * @author xgqfrms * @license MIT ...
- [CSSinJS] Convert Sass (SCSS) Styled Button to CSSinJS with JavaScript Templates and Variables
This is an introduction to CSSinJS that doesn't require any JavaScript knowledge, just a basic CSS. ...
- [SCSS] Organize SCSS into Multiple Files with Partials
Tired of dealing with monolithic CSS files? Are requests for multiple CSS files hurting your perform ...
- javascript arguments与javascript函数重载
1.所 有的函数都有属于自己的一个arguments对象,它包括了函所要调用的参数.他不是一个数组,如果用typeof arguments,返回的是’object’.虽然我们可以用调用数据的方法来调用 ...
- 预编译scss以及scss和less px 转rem
预编译scss步骤: 1 搜索ruby并安装,点击 2 安装sass: 3 在hubuilder工具中设置预编译: 触发命令地址为ruby安装地址 命令参数为 %FileName% %FileBase ...
- [Javascript] Required function arguments in Javascript
In Javascript, all function arguments are optional by default. That means if you ever forget to pass ...
- To add private variable to this Javascript literal object
You can use number as function/variable name, the numberic name can't be accessed from parent scope, ...
- listening for variable changes in javascript
https://stackoverflow.com/questions/1759987/listening-for-variable-changes-in-javascript
- Sass使用教程
sass官网: http://sass-lang.com/ http://sass-lang.com/documentation/file.SASS_REFERENCE.html Sass和Scss的 ...
随机推荐
- bzoj1895
fhqtreap 其实fhqtreap只有可持久化之后才用新建节点... reverse和splay一样. //#include<bits/stdc++.h> #include<cs ...
- Wall(凸包)
http://poj.org/problem?id=1113 题意:给出一些点的坐标,和一个半径r,求出这些点围成的凸包的周长再加上一个半径为r的圆的周长. #include <stdio.h& ...
- thinkphp session db配置
这篇文章主要介绍了ThinkPHP实现将SESSION存入MYSQL的方法,需要的朋友可以参考下 本文以实例讲解了ThinkPHP实现将SESSION存入MYSQL的方法,所采用的运行环境是Thi ...
- 【贪心】小Y的炮[cannon]题解
模拟赛的题目,做的时候由于第二题表打太久了,只剩下40分钟,想都没想就写了一个爆搜20分... 这道题单调性很关键,下面会解释 P.S.解释在代码里 #include<cstdio> #i ...
- HDU 1054 Hungary
Strategic Game Problem Description Bob enjoys playing computer games, especially strategic games, bu ...
- itext 生成doc文档 小结(自己备忘)
1.引入maven <dependency> <groupId>com.lowagie</groupId> <artifactId>itext</ ...
- 关于VM虚拟机在使用网络时与锐捷网络冲突的解决问题
在使用NAT网络模式的时候,锐捷会因为冲突强制关闭NAT服务,导致虚拟机无法上网,解决的办法是让NAT服务一直保持启动,写一个bat脚本来一直检测服务是否在运行,并且进行启动操作. 当不需要用虚拟机的 ...
- ★Java语法(四)——————————运算符
使用除法“/” ,要特别注意数据类型的问题.若被除数和除数都是整形,且被除数不能被除数整除时,这时输出的结果为整数,(即整形数/整形数=整形数),这是因为整形变量无法保存小数点后面的数据所致,要特别 ...
- VHDL之concurrent之block
1 Simple BLOCK The simple block represents only a way of partitioning the code. It allows concurrent ...
- HDU_1729_sg函数(dfs)
Stone Game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total ...