Sass数据类型
S.N. |
数据类型及说明
|
示例 |
---|---|---|
1 |
Numbers
它代表整数类型
|
2, 10.5 |
2 |
Strings
单或双引号中定义的字符序列
|
'BootWiki', "bootwiki" |
3 |
Colors
用于定义颜色值
|
red, #008000, rgb(25,255,204) |
4 |
Booleans
布尔类型返回true或false
|
10 > 9 指示为 true |
5 |
Nulls
它指定为空值,未知的数据
|
if(val==null) {//statements} |
6 |
Space and Comm
表示由空格或逗号分隔值
|
1px solid #eeeeee, 0 0 0 1px |
7 |
Mapping
它从一个值映射到另一个值
|
FirsyKey: frstvalue, SecondKey: secvalue |
字符串
示例
<html>
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>字符串 - www.bootwiki.com</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>字符串使用示例</h2>
<p class="bootwiki">Sass is an extension of CSS that adds power and elegance to the basic language.</p>
</div>
</body>
</html>
接下来,产生一个文件:style.scss.
style.scss
$name: "bootwiki"; p.#{$name} { color: blue; }
sass --watch C:Ruby22-x64style.scss:style.css
style.css
p.yiibai{ color: blue; }
输出结果
-
保存上述的HTML代码到strings.html文件。
-
在浏览器中打开该HTML文件,输出如下得到显示。
Lists
-
nth 函数: 它提供了列表的特定的项目
-
join 函数: 它将多个列表加入成为一个列表
-
append 函数: 追加的项目到列表的另一端
-
@each 指令: 它提供列表中每个项目的样式
10px 11px, 15px 16px
{10px 11px} {15px 16px}
Maps
$map: (FirsyKey: frstvalue, SecondKey: secvalue, Thirdkey: thdvalue);
-
map-get: 提供映射的值。
-
map-merge: 它增加值到映射中
-
@each directive: 它规定了键/值对映射的样式
Colors