stylus入门使用方法
<div class="article_meta" style="color: rgb(153, 153, 153); padding-bottom: 5px; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: rgb(211, 211, 211); font-family: "Helvetica Neue", Helvetica, Tahoma, Arial, STXihei, "Microsoft YaHei", 微软雅黑, sans-serif;"><div class="source"><span style="float: left;">原文</span> <a class="cut cut70" href="http://segmentfault.com/a/1190000002712872?utm_source=tuicool&utm_medium=referral" style="color: rgb(51, 51, 51); text-decoration: none; transition: 0.25s; outline: none 0px; overflow: hidden; white-space: nowrap; word-break: keep-all; text-overflow: ellipsis; max-width: 69%; display: inline-block;">http://segmentfault.com/a/1190000002712872</a></div><div><span style="margin-right: 5px;">主题</span> <a href="http://www.tuicool.com/topics/11060002" target="_blank" style="color: rgb(51, 51, 51); text-decoration: none; transition: 0.25s; outline: none 0px;"><span class="new-label" style="display: inline-block; padding: 2px 4px; font-size: 0.9em; line-height: 16px; vertical-align: baseline; white-space: nowrap; color: rgb(120, 120, 120); margin-right: 5px; background-color: rgb(242, 242, 242);">CSS</span></a></div></div><div class="article_body" id="nei" style="padding: 20px 5px 25px; overflow-x: hidden; word-break: break-all; min-height: 340px; font-size: 16px; line-height: 1.7em; color: rgb(51, 51, 51); font-family: "Helvetica Neue", Helvetica, Tahoma, Arial, STXihei, "Microsoft YaHei", 微软雅黑, sans-serif;"><div style="line-height: 1.7em;"><h2 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">stylus介绍</h2><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">是个什么鬼?对于开发来说,CSS的弱点在于静态化。我们需要一个真正能提高开发效率的工具, <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">LESS</code> , <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">SASS</code> 都在这方面做了一些贡献。</p><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;"><code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">Stylus</code> 是一个CSS的预处理框架,2010年产生,来自Node.js社区,主要用来给Node项目进行CSS预处理支持,所以 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">Stylus</code> 是一种新型语言,可以创建健壮的、动态的、富有表现力的CSS。比较年轻,其本质上做的事情与 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">SASS</code> / <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">LESS</code> 等类似,应该是有很多借鉴,所以近似脚本的方式去写CSS代码。</p><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;"><code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">Stylus</code> 默认使用 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">.styl</code> 的作为文件扩展名,支持多样性的CSS语法。</p><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;"><code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">Stylus</code> 功能上更为强壮,和js联系更加紧密。所以我选择 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">Stylus</code> , <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">SASS</code> 玩儿过一段时间,主要是这玩意依赖ruby运行,所以我放弃使用了。</p><h2 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">文档参考</h2><div style="line-height: 1.7em;"><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;"><a rel="nofollow,noindex" href="http://learnboost.github.io/stylus/" style="color: rgb(148, 148, 148); text-decoration: none; transition: 0.25s; outline: none 0px; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: rgb(148, 148, 148); font-style: italic; font-weight: bold;">官方Stylus API</a></p><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;"><a rel="nofollow,noindex" href="http://www.zhangxinxu.com/jq/stylus/" style="color: rgb(148, 148, 148); text-decoration: none; transition: 0.25s; outline: none 0px; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: rgb(148, 148, 148); font-style: italic; font-weight: bold;">张鑫旭中文翻译</a></p><a rel="nofollow,noindex" href="http://learnboost.github.io/stylus/try.html" style="color: rgb(148, 148, 148); text-decoration: none; transition: 0.25s; outline: none 0px; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: rgb(148, 148, 148); font-style: italic; font-weight: bold;">Try Stylus!</a></div><h2 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">Stylus安装</h2><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">全局安装,安装之前你需要你安装 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">nodejs</code> 这个怎么安装搜去哦。</p><pre class="ruby" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 0.75em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="variable" style="color: rgb(0, 128, 128);">$ </span>npm install stylus -g</code></pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">这样就算是安装完Stylus了,也可以正常使用Stylus。</p><pre class="prettyprint javascript" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">Usage: stylus [<span class="xml"><span class="tag" style="color: rgb(0, 0, 128);">< <span class="attribute" style="color: rgb(0, 128, 128);">in</span> [></span> out]]
Commands:
help <span class="tag" style="color: rgb(0, 0, 128);"><<span class="title">prop</span>></span> Opens help info for <span class="tag" style="color: rgb(0, 0, 128);"><<span class="title">prop</span>></span> in
your default browser. (OS X only)
Options:
-u, --use <span class="tag" style="color: rgb(0, 0, 128);"><<span class="title">path</span>></span> Utilize the stylus plugin at <span class="tag" style="color: rgb(0, 0, 128);"><<span class="title">path</span>></span>
-i, --interactive Start interactive REPL
-w, --watch Watch file(s) for changes and re-compile
-o, --out <span class="tag" style="color: rgb(0, 0, 128);"><<span class="title">dir</span>></span> Output to <span class="tag" style="color: rgb(0, 0, 128);"><<span class="title">dir</span>></span> when passing files
-C, --css <span class="tag" style="color: rgb(0, 0, 128);"><<span class="title">src</span>></span> Convert CSS input to Stylus
-I, --include <span class="tag" style="color: rgb(0, 0, 128);"><<span class="title">path</span>></span> Add <span class="tag" style="color: rgb(0, 0, 128);"><<span class="title">path</span>></span> to lookup paths
-c, --compress Compress CSS output
-d, --compare Display input along with output
-f, --firebug Emits debug infos in the generated css that
can be used by the FireStylus Firebug plugin
-l, --line-numbers Emits comments in the generated CSS
indicating the corresponding Stylus line
-V, --version Display the version of Stylus
-h, --help Display help information
</span></code></pre><h2 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">生成CSS</h2><h3 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">命令行中</h3><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">建立一个 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">stylusExample/</code> ,再在里面建立 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">src</code> 目录专门存放 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">stylus</code> 文件,在里面建立 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">example.styl</code> 文件。然后在 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">stylusExample</code> 目录下面执行下面命令</p><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">$ stylus --compress src/</p><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">输出 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">compiled src/example.css</code> ,这个时候表示你生成成功了,带上 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">--compress</code> 参数表示你生成压缩的CSS文件。</p><div style="line-height: 1.7em;"><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;"><code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">$ stylus --css css/example.css css/out.styl</code> CSS转换成styl</p><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;"><code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">$ stylus help box-shadow</code> CSS属性的帮助</p><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;"><code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">$ stylus --css test.css</code> 输出基本名一致的.styl文件</p></div><h3 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">grunt生成</h3><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">grunt生成 就比较爽歪歪了,具体grunt怎么玩儿,俺写了个教程 <a rel="nofollow,noindex" href="http://jslite.io/2015/04/09/Grunt%E6%95%99%E7%A8%8B-%E5%89%8D%E7%AB%AF%E8%87%AA%E5%8A%A8%E5%8C%96/" style="color: rgb(148, 148, 148); text-decoration: none; transition: 0.25s; outline: none 0px; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: rgb(148, 148, 148); font-style: italic; font-weight: bold;">Grunt教程-前端自动化</a> 可以学习以下。</p><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylusExample 目录下创建两个文件,这两个文件是grunt必备文件。</p><div style="line-height: 1.7em;"><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">package.json:用于保存项目元数据。Gruntfile.js:用于配置或定义任务、加载 Grunt 插件。</p></div><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">package.json 内容</p><pre class="prettyprint undefined" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">json</code><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">{
"name": "test",
"version": "1.0.0",
"description": "测试的例子",
"repository": {
"type": "git",
"url": ""
}
}
</code></pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">然后安装必备插件,这些插件让stylus文件变更了自动生成,生成到相对应的文件目录中。如果报错你需要在命令行前面加上sudo,给它最大的执行权限。</p><div style="line-height: 1.7em;"><code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">npm install grunt --save-dev</code><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;"><code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">npm install grunt-contrib-watch --save-dev</code> :监视文件变动,做出相应动作。 <a rel="nofollow,noindex" href="https://www.npmjs.com/package/grunt-contrib-watch" style="color: rgb(148, 148, 148); text-decoration: none; transition: 0.25s; outline: none 0px; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: rgb(148, 148, 148); font-style: italic; font-weight: bold;">npm>></a></p><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;"><code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">npm install grunt-contrib-stylus --save-dev</code> :stylus编写styl输出css <a rel="nofollow,noindex" href="https://www.npmjs.com/package/grunt-contrib-stylus" style="color: rgb(148, 148, 148); text-decoration: none; transition: 0.25s; outline: none 0px; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: rgb(148, 148, 148); font-style: italic; font-weight: bold;">npm>></a></p></div><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">安装出现这样的警告 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">npm WARN package.json test@1.0.0 No README data</code>可以不理会,如果你看着不舒服,你需要在stylusExample目录下面建立一个 README.md 文件并输入内容。也可命令执行 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">echo "#stylus 学习" >> README.md</code></p><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">插件执行完毕之后 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">package.json</code> 文件变成了这样样子滴。</p><pre class="prettyprint undefined" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">json</code><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">{
"name": "test",
"version": "1.0.0",
"description": "测试的例子",
"repository": {
"type": "git",
"url": ""
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-stylus": "^0.21.0",
"grunt-contrib-watch": "^0.6.1"
}
}
</code></pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">这个时候你需要使用这些插件儿完成你的任务需要在 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">Gruntfile.js</code> 里面写你的执行任务。</p><pre class="prettyprint cs" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">js</code><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="comment" style="color: rgb(153, 153, 136); font-style: italic;"><span class="xmlDocTag">///</span> 包装函数</span>
module.exports = function(grunt) {
<span class="indent"></span><span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">// 任务配置,所有插件的配置信息</span>
<span class="indent"></span>grunt.initConfig({
<span class="indent"></span><span class="indent"></span>pkg: grunt.file.readJSON(<span class="string" style="color: rgb(221, 17, 68);">'package.json'</span>),
<span class="indent"></span><span class="indent"></span>stylus:{
<span class="indent"></span><span class="indent"></span><span class="indent"></span>build: {
<span class="indent"></span><span class="indent"></span><span class="indent"></span><span class="indent"></span>options: {
<span class="indent"></span><span class="indent"></span><span class="indent"></span><span class="indent"></span><span class="indent"></span>linenos: <span class="keyword" style="font-weight: bold;">false</span>,
<span class="indent"></span><span class="indent"></span><span class="indent"></span><span class="indent"></span><span class="indent"></span>compress: <span class="keyword" style="font-weight: bold;">true</span>
<span class="indent"></span><span class="indent"></span><span class="indent"></span><span class="indent"></span>},
<span class="indent"></span><span class="indent"></span><span class="indent"></span><span class="indent"></span>files: [{
<span class="indent"></span><span class="indent"></span><span class="indent"></span><span class="indent"></span><span class="indent"></span><span class="string" style="color: rgb(221, 17, 68);">'css/index.css'</span>: [<span class="string" style="color: rgb(221, 17, 68);">'src/index.styl'</span>]
<span class="indent"></span><span class="indent"></span><span class="indent"></span><span class="indent"></span>}]
<span class="indent"></span><span class="indent"></span><span class="indent"></span>}
<span class="indent"></span><span class="indent"></span>},
<span class="indent"></span><span class="indent"></span><span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">// watch插件的配置信息</span>
<span class="indent"></span><span class="indent"></span>watch: {
<span class="indent"></span><span class="indent"></span><span class="indent"></span>another: {
<span class="indent"></span><span class="indent"></span><span class="indent"></span><span class="indent"></span>files: [<span class="string" style="color: rgb(221, 17, 68);">'css/*'</span>,<span class="string" style="color: rgb(221, 17, 68);">'src/*.styl'</span>],
<span class="indent"></span><span class="indent"></span><span class="indent"></span><span class="indent"></span>tasks: [<span class="string" style="color: rgb(221, 17, 68);">'stylus'</span>],
<span class="indent"></span><span class="indent"></span><span class="indent"></span><span class="indent"></span>options: {
<span class="indent"></span><span class="indent"></span><span class="indent"></span><span class="indent"></span><span class="indent"></span>livereload: <span class="number" style="color: rgb(0, 153, 153);">1337</span>
<span class="indent"></span><span class="indent"></span><span class="indent"></span><span class="indent"></span>}
<span class="indent"></span><span class="indent"></span><span class="indent"></span>}
<span class="indent"></span><span class="indent"></span>}
<span class="indent"></span>});
<span class="indent"></span><span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">// 告诉grunt我们将使用插件</span>
<span class="indent"></span>grunt.loadNpmTasks(<span class="string" style="color: rgb(221, 17, 68);">'grunt-contrib-watch'</span>);
<span class="indent"></span>grunt.loadNpmTasks(<span class="string" style="color: rgb(221, 17, 68);">'grunt-contrib-stylus'</span>);
<span class="indent"></span><span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">// 告诉grunt当我们在终端中输入grunt时需要做些什么</span>
<span class="indent"></span>grunt.registerTask(<span class="string" style="color: rgb(221, 17, 68);">'default'</span>, [<span class="string" style="color: rgb(221, 17, 68);">'watch'</span>]);
};
</code>
</pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">注意读懂上面的哦,目录高对哦,这些没有必要提醒哦,这个时候你可以好好耍一下stylus</p><h2 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">Stylus应用</h2><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">这个时候真正的开始玩耍了哦。</p><h3 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">Try Stylus!</h3><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus</p><pre class="css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 0.75em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">body</span>,<span class="tag" style="color: rgb(0, 0, 128);">html</span>
<span class="tag" style="color: rgb(0, 0, 128);">margin</span><span class="pseudo">:0</span>
<span class="tag" style="color: rgb(0, 0, 128);">padding</span><span class="pseudo">:0</span>
</code></pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 0.75em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><span class="tag" style="color: rgb(0, 0, 128);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; color: rgb(51, 51, 51); border-radius: 3px; border: 0px; display: block; overflow-y: auto;">body</code></span><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">,
<span class="tag" style="color: rgb(0, 0, 128);">html</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">margin</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">0</span>;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">padding</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">0</span>;</span></span>
<span class="rule">}</span></span>
</code></pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus : 强大的功能丰富的语言</p><pre class="prettyprint cs" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">-pos(type, args)
i = <span class="number" style="color: rgb(0, 153, 153);">0</span>
position: unquote(type)
{args}: args <span class="keyword" style="font-weight: bold;">is</span> a <span class="string" style="color: rgb(221, 17, 68);">'unit'</span> ? args : <span class="number" style="color: rgb(0, 153, 153);">0</span>
{args}: args <span class="keyword" style="font-weight: bold;">is</span> a <span class="string" style="color: rgb(221, 17, 68);">'unit'</span> ? args : <span class="number" style="color: rgb(0, 153, 153);">0</span>
absolute()
-pos(<span class="string" style="color: rgb(221, 17, 68);">'absolute'</span>, arguments)
<span class="keyword" style="font-weight: bold;">fixed</span>()
-pos(<span class="string" style="color: rgb(221, 17, 68);">'fixed'</span>, arguments)
<span class="preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#prompt</span>
absolute: top <span class="number" style="color: rgb(0, 153, 153);">150</span>px left <span class="number" style="color: rgb(0, 153, 153);">5</span>px
width: <span class="number" style="color: rgb(0, 153, 153);">200</span>px
margin-left: -(@width / <span class="number" style="color: rgb(0, 153, 153);">2</span>)
<span class="preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#logo</span>
<span class="keyword" style="font-weight: bold;">fixed</span>: top left
</code></pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="prettyprint css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="id" style="color: rgb(153, 0, 0); font-weight: bold;">#prompt</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">position</span>:<span class="value"> absolute;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">top</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">150</span>px;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">left</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">5</span>px;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">width</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">200</span>px;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">margin-left</span>:<span class="value"> -<span class="number" style="color: rgb(0, 153, 153);">100</span>px;</span></span>
<span class="rule">}</span></span>
<span class="id" style="color: rgb(153, 0, 0); font-weight: bold;">#logo</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">position</span>:<span class="value"> fixed;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">top</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">0</span>;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">left</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">0</span>;</span></span>
<span class="rule">}</span></span>
</code></pre><h3 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">nibStylus插件</h3><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus</p><pre class="prettyprint css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="at_rule">@<span class="keyword" style="font-weight: bold;">import</span> <span class="string" style="color: rgb(221, 17, 68);">'nib'</span>
body
background: linear-<span class="function">gradient(<span class="number" style="color: rgb(0, 153, 153);">20</span>px top, white, black)</span>
</span></code></pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="prettyprint css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><span class="tag" style="color: rgb(0, 0, 128);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; color: rgb(51, 51, 51); border-radius: 3px; border: 0px; display: block; overflow-y: auto;">body</code></span><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">background</span>:<span class="value"> -webkit-linear-<span class="function">gradient(<span class="number" style="color: rgb(0, 153, 153);">20</span>px top, #fff, #<span class="number" style="color: rgb(0, 153, 153);">000</span>)</span>;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">background</span>:<span class="value"> -moz-linear-<span class="function">gradient(<span class="number" style="color: rgb(0, 153, 153);">20</span>px top, #fff, #<span class="number" style="color: rgb(0, 153, 153);">000</span>)</span>;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">background</span>:<span class="value"> -o-linear-<span class="function">gradient(<span class="number" style="color: rgb(0, 153, 153);">20</span>px top, #fff, #<span class="number" style="color: rgb(0, 153, 153);">000</span>)</span>;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">background</span>:<span class="value"> -ms-linear-<span class="function">gradient(<span class="number" style="color: rgb(0, 153, 153);">20</span>px top, #fff, #<span class="number" style="color: rgb(0, 153, 153);">000</span>)</span>;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">background</span>:<span class="value"> linear-<span class="function">gradient(<span class="number" style="color: rgb(0, 153, 153);">20</span>px top, #fff, #<span class="number" style="color: rgb(0, 153, 153);">000</span>)</span>;</span></span>
<span class="rule">}</span></span>
</code></pre><h3 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">Nesting(嵌套)</h3><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus</p><pre class="css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 0.75em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">header</span>
<span class="id" style="color: rgb(153, 0, 0); font-weight: bold;">#logo</span>
<span class="tag" style="color: rgb(0, 0, 128);">border</span><span class="pseudo">:1px</span> <span class="tag" style="color: rgb(0, 0, 128);">solid</span> <span class="tag" style="color: rgb(0, 0, 128);">red</span>
</code></pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 0.75em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><span class="tag" style="color: rgb(0, 0, 128);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; color: rgb(51, 51, 51); border-radius: 3px; border: 0px; display: block; overflow-y: auto;">header</code></span><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"> <span class="id" style="color: rgb(153, 0, 0); font-weight: bold;">#logo</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">border</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">1</span>px solid <span class="hexcolor" style="color: rgb(0, 153, 153);">#f00</span>;</span></span>
<span class="rule">}</span></span>
</code></pre><h3 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">Flexible syntax(灵活的用法)</h3><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus</p><pre class="prettyprint bash" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">body
<span class="indent"></span>font 14px/1.5 Helvetica, arial, sans-serif
<span class="indent"></span>button
<span class="indent"></span>button.button
<span class="indent"></span>input
<span class="indent"></span>input
<span class="indent"></span><span class="indent"></span>border-radius 5px
header
<span class="indent"></span><span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">#logo,div</span>
<span class="indent"></span><span class="indent"></span>font-size:14px
</code>
</pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="prettyprint css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><span class="tag" style="color: rgb(0, 0, 128);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; color: rgb(51, 51, 51); border-radius: 3px; border: 0px; display: block; overflow-y: auto;">body</code></span><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">font</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">14</span>px/<span class="number" style="color: rgb(0, 153, 153);">1.5</span> Helvetica, arial, sans-serif;</span></span>
<span class="rule">}</span></span>
<span class="tag" style="color: rgb(0, 0, 128);">body</span> <span class="tag" style="color: rgb(0, 0, 128);">button</span>,
<span class="tag" style="color: rgb(0, 0, 128);">body</span> <span class="tag" style="color: rgb(0, 0, 128);">button</span><span class="class" style="color: rgb(68, 85, 136); font-weight: bold;">.button</span>,
<span class="tag" style="color: rgb(0, 0, 128);">body</span> <span class="tag" style="color: rgb(0, 0, 128);">input</span><span class="attr_selector"></span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">border-radius</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">5</span>px;</span></span>
<span class="rule">}</span></span>
<span class="tag" style="color: rgb(0, 0, 128);">header</span> <span class="id" style="color: rgb(153, 0, 0); font-weight: bold;">#logo</span>,
<span class="tag" style="color: rgb(0, 0, 128);">header</span> <span class="tag" style="color: rgb(0, 0, 128);">div</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">font-size</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">14</span>px;</span></span>
<span class="rule">}</span></span>
</code></pre><h3 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">Flexible &(灵活&)</h3><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus</p><pre class="prettyprint sql" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">ul
<span class="indent"></span>li a
<span class="indent"></span><span class="indent"></span>display: b<span class="operator"><span class="keyword" style="font-weight: bold;">lock</span>
<span class="indent"></span><span class="indent"></span>color: blue
<span class="indent"></span><span class="indent"></span>padding: <span class="number" style="color: rgb(0, 153, 153);">5</span>px
<span class="indent"></span><span class="indent"></span>html.ie &
<span class="indent"></span><span class="indent"></span><span class="indent"></span>padding: <span class="number" style="color: rgb(0, 153, 153);">6</span>px
<span class="indent"></span><span class="indent"></span>&:hover
<span class="indent"></span><span class="indent"></span><span class="indent"></span>color: red
</span></code><span class="operator">
</span></pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="prettyprint css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><span class="tag" style="color: rgb(0, 0, 128);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; color: rgb(51, 51, 51); border-radius: 3px; border: 0px; display: block; overflow-y: auto;">ul</code></span><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"> <span class="tag" style="color: rgb(0, 0, 128);">li</span> <span class="tag" style="color: rgb(0, 0, 128);">a</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">display</span>:<span class="value"> block;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">color</span>:<span class="value"> <span class="hexcolor" style="color: rgb(0, 153, 153);">#00f</span>;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">padding</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">5</span>px;</span></span>
<span class="rule">}</span></span>
<span class="tag" style="color: rgb(0, 0, 128);">html</span><span class="class" style="color: rgb(68, 85, 136); font-weight: bold;">.ie</span> <span class="tag" style="color: rgb(0, 0, 128);">ul</span> <span class="tag" style="color: rgb(0, 0, 128);">li</span> <span class="tag" style="color: rgb(0, 0, 128);">a</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">padding</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">6</span>px;</span></span>
<span class="rule">}</span></span>
<span class="tag" style="color: rgb(0, 0, 128);">ul</span> <span class="tag" style="color: rgb(0, 0, 128);">li</span> <span class="tag" style="color: rgb(0, 0, 128);">a</span><span class="pseudo">:hover</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">color</span>:<span class="value"> <span class="hexcolor" style="color: rgb(0, 153, 153);">#f00</span>;</span></span>
<span class="rule">}</span></span>
</code></pre><h3 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">Functions 方法</h3><h4 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.7em; color: inherit; text-rendering: optimizeLegibility; text-indent: 1em;">返回值</h4><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus</p><pre class="prettyprint undefined" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">border-radius(val)
<span class="indent"></span>-webkit-border-radius: val
<span class="indent"></span>-moz-border-radius: val
<span class="indent"></span>border-radius: val
button
<span class="indent"></span>border-radius(5px);
</code>
</pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="prettyprint css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><span class="tag" style="color: rgb(0, 0, 128);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; color: rgb(51, 51, 51); border-radius: 3px; border: 0px; display: block; overflow-y: auto;">button</code></span><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">-webkit-border-radius</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">5</span>px;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">-moz-border-radius</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">5</span>px;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">border-radius</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">5</span>px;</span></span>
<span class="rule">}</span></span>
</code></pre><h4 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.7em; color: inherit; text-rendering: optimizeLegibility; text-indent: 1em;">Transparent mixins</h4><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">不带参数</p><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus</p><pre class="prettyprint undefined" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">border-radius()
<span class="indent"></span>-webkit-border-radius: arguments
<span class="indent"></span>-moz-border-radius: arguments
<span class="indent"></span>border-radius: arguments
button
<span class="indent"></span>border-radius: 5px 10px;
</code>
</pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="prettyprint css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><span class="tag" style="color: rgb(0, 0, 128);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; color: rgb(51, 51, 51); border-radius: 3px; border: 0px; display: block; overflow-y: auto;">button</code></span><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">-webkit-border-radius</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">5</span>px <span class="number" style="color: rgb(0, 153, 153);">10</span>px;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">-moz-border-radius</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">5</span>px <span class="number" style="color: rgb(0, 153, 153);">10</span>px;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">border-radius</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">5</span>px <span class="number" style="color: rgb(0, 153, 153);">10</span>px;</span></span>
<span class="rule">}</span></span>
</code></pre><h4 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.7em; color: inherit; text-rendering: optimizeLegibility; text-indent: 1em;">默认参数</h4><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">不带参数</p><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus</p><pre class="prettyprint cs" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">add(a, b = a)
a + b
add(<span class="number" style="color: rgb(0, 153, 153);">10</span>, <span class="number" style="color: rgb(0, 153, 153);">5</span>)
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">// => 15</span>
add(<span class="number" style="color: rgb(0, 153, 153);">10</span>)
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">// => 20</span>
</code></pre><h4 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.7em; color: inherit; text-rendering: optimizeLegibility; text-indent: 1em;">函数体</h4><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">通过内置unit()把单位都变成px, 因为赋值在每个参数上,因此,我们可以无视单位换算。</p><pre class="prettyprint cs" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">add(a, b = a)
a = unit(a, px)
b = unit(b, px)
a + b
add(<span class="number" style="color: rgb(0, 153, 153);">15</span>%, <span class="number" style="color: rgb(0, 153, 153);">10</span>deg)
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">// => 25</span>
</code></pre><h4 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.7em; color: inherit; text-rendering: optimizeLegibility; text-indent: 1em;">多个返回值</h4><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">通过内置unit()把单位都变成px, 因为赋值在每个参数上,因此,我们可以无视单位换算。</p><pre class="cs" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 0.75em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">sizes()
<span class="number" style="color: rgb(0, 153, 153);">15</span>px <span class="number" style="color: rgb(0, 153, 153);">10</span>px
sizes()[<span class="number" style="color: rgb(0, 153, 153);">0</span>]
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">// => 15px</span>
</code></pre><h3 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">Variables(变量)</h3><h4 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.7em; color: inherit; text-rendering: optimizeLegibility; text-indent: 1em;">常用方法</h4><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus</p><pre class="undefined" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 0.75em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">font-size = 14px
body
font font-size Arial, sans-seri
</code></pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 0.75em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><span class="tag" style="color: rgb(0, 0, 128);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; color: rgb(51, 51, 51); border-radius: 3px; border: 0px; display: block; overflow-y: auto;">body</code></span><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">font</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">14</span>px Arial, sans-seri;</span></span>
<span class="rule">}</span></span>
</code></pre><h4 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.7em; color: inherit; text-rendering: optimizeLegibility; text-indent: 1em;">变量放在属性中</h4><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus</p><pre class="prettyprint bash" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">#prompt</span>
<span class="indent"></span>position: absolute
<span class="indent"></span>top: 150px
<span class="indent"></span>left: 50%
<span class="indent"></span>width: w = 200px
<span class="indent"></span>margin-left: -(w / 2)
</code>
</pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="prettyprint css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="id" style="color: rgb(153, 0, 0); font-weight: bold;">#prompt</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">position</span>:<span class="value"> absolute;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">top</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">150</span>px;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">left</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">50</span>%;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">width</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">200</span>px;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">margin-left</span>:<span class="value"> -<span class="number" style="color: rgb(0, 153, 153);">100</span>px;</span></span>
<span class="rule">}</span></span>
</code></pre><h4 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.7em; color: inherit; text-rendering: optimizeLegibility; text-indent: 1em;">块属性访问引用</h4><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus</p><pre class="prettyprint ruby" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">#prompt</span>
<span class="symbol" style="color: rgb(153, 0, 115);">position:</span> absolute
<span class="symbol" style="color: rgb(153, 0, 115);">width:</span> <span class="number" style="color: rgb(0, 153, 153);">200</span>px
margin-<span class="symbol" style="color: rgb(153, 0, 115);">left:</span> -(<span class="variable" style="color: rgb(0, 128, 128);">@width</span> / <span class="number" style="color: rgb(0, 153, 153);">2</span>)
</code></pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="prettyprint css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="id" style="color: rgb(153, 0, 0); font-weight: bold;">#prompt</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">position</span>:<span class="value"> absolute;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">width</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">200</span>px;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">margin-left</span>:<span class="value"> -<span class="number" style="color: rgb(0, 153, 153);">100</span>px;</span></span>
<span class="rule">}</span></span>
</code></pre><h4 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.7em; color: inherit; text-rendering: optimizeLegibility; text-indent: 1em;">属性有条件地定义属性</h4><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus:指定z-index值为1,但是,只有在z-index之前未指定的时候才这样:</p><pre class="prettyprint perl" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">position()
position: arguments
z-<span class="keyword" style="font-weight: bold;">index</span>: <span class="number" style="color: rgb(0, 153, 153);">1</span> <span class="keyword" style="font-weight: bold;">unless</span> <span class="variable" style="color: rgb(0, 128, 128);">@z</span>-<span class="keyword" style="font-weight: bold;">index</span>
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">#logo</span>
z-<span class="keyword" style="font-weight: bold;">index</span>: <span class="number" style="color: rgb(0, 153, 153);">20</span>
position: absolute
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">#logo2</span>
position: absolute
</code></pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="prettyprint css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="id" style="color: rgb(153, 0, 0); font-weight: bold;">#logo</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">z-index</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">20</span>;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">position</span>:<span class="value"> absolute;</span></span>
<span class="rule">}</span></span>
<span class="id" style="color: rgb(153, 0, 0); font-weight: bold;">#logo2</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">position</span>:<span class="value"> absolute;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">z-index</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">1</span>;</span></span>
<span class="rule">}</span></span>
</code></pre><h4 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.7em; color: inherit; text-rendering: optimizeLegibility; text-indent: 1em;">向上冒泡</h4><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus:属性会“向上冒泡”查找堆栈直到被发现,或者返回null(如果属性搞不定)下面这个例子,@color被弄成了blue.</p><pre class="prettyprint ruby" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">body
<span class="symbol" style="color: rgb(153, 0, 115);">color:</span> red
ul
li
<span class="symbol" style="color: rgb(153, 0, 115);">color:</span> blue
a
background-<span class="symbol" style="color: rgb(153, 0, 115);">color:</span> <span class="variable" style="color: rgb(0, 128, 128);">@color</span>
</code></pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="prettyprint css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><span class="tag" style="color: rgb(0, 0, 128);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; color: rgb(51, 51, 51); border-radius: 3px; border: 0px; display: block; overflow-y: auto;">body</code></span><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">color</span>:<span class="value"> <span class="hexcolor" style="color: rgb(0, 153, 153);">#f00</span>;</span></span>
<span class="rule">}</span></span>
<span class="tag" style="color: rgb(0, 0, 128);">body</span> <span class="tag" style="color: rgb(0, 0, 128);">ul</span> <span class="tag" style="color: rgb(0, 0, 128);">li</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">color</span>:<span class="value"> <span class="hexcolor" style="color: rgb(0, 153, 153);">#00f</span>;</span></span>
<span class="rule">}</span></span>
<span class="tag" style="color: rgb(0, 0, 128);">body</span> <span class="tag" style="color: rgb(0, 0, 128);">ul</span> <span class="tag" style="color: rgb(0, 0, 128);">li</span> <span class="tag" style="color: rgb(0, 0, 128);">a</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">background-color</span>:<span class="value"> <span class="hexcolor" style="color: rgb(0, 153, 153);">#00f</span>;</span></span>
<span class="rule">}</span></span>
</code></pre><h3 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">Iteration(迭代)</h3><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus</p><pre class="prettyprint bash" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">table
<span class="keyword" style="font-weight: bold;">for</span> row <span class="keyword" style="font-weight: bold;">in</span> 1 2 3 4 5
tr:nth-child({row})
height: 10px * row
</code></pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="prettyprint css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><span class="tag" style="color: rgb(0, 0, 128);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; color: rgb(51, 51, 51); border-radius: 3px; border: 0px; display: block; overflow-y: auto;">table</code></span><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"> <span class="tag" style="color: rgb(0, 0, 128);">tr</span><span class="pseudo">:nth-child(1)</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">height</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">10</span>px;</span></span>
<span class="rule">}</span></span>
<span class="tag" style="color: rgb(0, 0, 128);">table</span> <span class="tag" style="color: rgb(0, 0, 128);">tr</span><span class="pseudo">:nth-child(2)</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">height</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">20</span>px;</span></span>
<span class="rule">}</span></span>
<span class="tag" style="color: rgb(0, 0, 128);">table</span> <span class="tag" style="color: rgb(0, 0, 128);">tr</span><span class="pseudo">:nth-child(3)</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">height</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">30</span>px;</span></span>
<span class="rule">}</span></span>
<span class="tag" style="color: rgb(0, 0, 128);">table</span> <span class="tag" style="color: rgb(0, 0, 128);">tr</span><span class="pseudo">:nth-child(4)</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">height</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">40</span>px;</span></span>
<span class="rule">}</span></span>
<span class="tag" style="color: rgb(0, 0, 128);">table</span> <span class="tag" style="color: rgb(0, 0, 128);">tr</span><span class="pseudo">:nth-child(5)</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">height</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">50</span>px;</span></span>
<span class="rule">}</span></span>
</code></pre><h3 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">Interpolation(插值)</h3><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus</p><pre class="prettyprint bash" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">vendors = webkit moz o ms official
border-radius()
<span class="indent"></span><span class="keyword" style="font-weight: bold;">for</span> vendor <span class="keyword" style="font-weight: bold;">in</span> vendors
<span class="indent"></span><span class="indent"></span><span class="keyword" style="font-weight: bold;">if</span> vendor == official
<span class="indent"></span><span class="indent"></span><span class="indent"></span>border-radius: arguments
<span class="indent"></span><span class="indent"></span><span class="keyword" style="font-weight: bold;">else</span>
<span class="indent"></span><span class="indent"></span><span class="indent"></span>-{vendor}-border-radius: arguments
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">#content</span>
<span class="indent"></span>border-radius: 5px
</code>
</pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="prettyprint css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="id" style="color: rgb(153, 0, 0); font-weight: bold;">#content</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">-webkit-border-radius</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">5</span>px;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">-moz-border-radius</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">5</span>px;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">-o-border-radius</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">5</span>px;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">-ms-border-radius</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">5</span>px;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">border-radius</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">5</span>px;</span></span>
<span class="rule">}</span></span>
</code></pre><h3 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">Operators(运算符)</h3><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">运算符优先级下表运算符优先级,从最高到最低:</p><pre class="prettyprint cs" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;">.
[]
! ~ + -
<span class="keyword" style="font-weight: bold;">is</span> defined
** * / %
+ -
... ..
<= >= < >
<span class="keyword" style="font-weight: bold;">in</span>
== <span class="keyword" style="font-weight: bold;">is</span> != <span class="keyword" style="font-weight: bold;">is</span> not isnt
<span class="keyword" style="font-weight: bold;">is</span> a
&& and || or
?:
= := ?= += -= *= /= %=
not
<span class="keyword" style="font-weight: bold;">if</span> unless
</code></pre><h3 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">@import</h3><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">@import &quot;reset.css&quot;</p><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">当使用 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">@import</code> 没有 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">.css</code> 扩展,会被认为是 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">Stylus</code> 片段(如: <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">@import "mixins/border-radius"</code> )。</p><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;"><code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">@import</code> 工作原理为:遍历目录队列,并检查任意目录中是否有该文件(类似node的require.paths)。该队列默认为单一路径,从 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">filename</code> 选项的 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">dirname</code> 衍生而来。 因此,如果你的文件名是 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">/tmp/testing/stylus/main.styl</code> ,导入将显现为<code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">/tmp/testing/stylus/</code> 。</p><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;"><code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">@import</code> 也支持索引形式。这意味着当你 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">@import blueprint</code> , 则会理解成 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">blueprint.styl</code> 或 <code style="padding: 2px 4px; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: none; background-color: rgb(247, 247, 249);">blueprint/index.styl</code> . 对于库而言,这很有用,既可以展示所有特征与功能,同时又能导入特征子集。</p><h3 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">@font-face</h3><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus</p><pre class="prettyprint ruby" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="variable" style="color: rgb(0, 128, 128);">@font</span>-face
font-family <span class="constant">Geo</span>
font-style normal
src url(fonts/geo_sans_light/<span class="constant">GensansLight</span>.ttf)
.ingeo
font-family <span class="constant">Geo</span>
</code></pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="prettyprint css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="at_rule">@<span class="keyword" style="font-weight: bold;">font-face</span></span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">font-family</span>:<span class="value"> Geo;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">font-style</span>:<span class="value"> normal;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">src</span>:<span class="value"> <span class="function">url(<span class="string" style="color: rgb(221, 17, 68);">"fonts/geo_sans_light/GensansLight.ttf"</span>)</span>;</span></span>
<span class="rule">}</span></span>
<span class="class" style="color: rgb(68, 85, 136); font-weight: bold;">.ingeo</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">font-family</span>:<span class="value"> Geo;</span></span>
<span class="rule">}</span></span>
</code></pre><h3 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">@media</h3><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus</p><pre class="perl" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 0.75em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="variable" style="color: rgb(0, 128, 128);">@media</span> <span class="keyword" style="font-weight: bold;">print</span>
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">#header</span>
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">#footer</span>
display none
</code></pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="prettyprint css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="at_rule">@<span class="keyword" style="font-weight: bold;">media</span> print </span>{
<span class="id" style="color: rgb(153, 0, 0); font-weight: bold;">#header</span>,
<span class="id" style="color: rgb(153, 0, 0); font-weight: bold;">#footer</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">display</span>:<span class="value"> none;</span></span>
<span class="rule">}</span></span>
}
</code></pre><h3 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">@keyframes</h3><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus</p><pre class="prettyprint css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="at_rule">@keyframes pulse
<span class="number" style="color: rgb(0, 153, 153);">0</span>%
background-color red
transform <span class="function">scale(<span class="number" style="color: rgb(0, 153, 153);">1.0</span>)</span> <span class="function">rotate(<span class="number" style="color: rgb(0, 153, 153);">0</span>deg)</span>
<span class="number" style="color: rgb(0, 153, 153);">33</span>%
background-color blue
-webkit-transform <span class="function">scale(<span class="number" style="color: rgb(0, 153, 153);">1.1</span>)</span> <span class="function">rotate(-<span class="number" style="color: rgb(0, 153, 153);">5</span>deg)</span>
</span></code></pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="prettyprint css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 1.5em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="at_rule">@-moz-keyframes pulse </span>{
0% <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">background-color</span>:<span class="value"> <span class="hexcolor" style="color: rgb(0, 153, 153);">#f00</span>;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">transform</span>:<span class="value"> <span class="function">scale(<span class="number" style="color: rgb(0, 153, 153);">1</span>)</span> <span class="function">rotate(<span class="number" style="color: rgb(0, 153, 153);">0</span>deg)</span>;</span></span>
<span class="rule">}</span></span>
33% <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">background-color</span>:<span class="value"> <span class="hexcolor" style="color: rgb(0, 153, 153);">#00f</span>;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">-webkit-transform</span>:<span class="value"> <span class="function">scale(<span class="number" style="color: rgb(0, 153, 153);">1.1</span>)</span> <span class="function">rotate(-<span class="number" style="color: rgb(0, 153, 153);">5</span>deg)</span>;</span></span>
<span class="rule">}</span></span>
}
<span class="at_rule">@-webkit-keyframes pulse </span>{
0% <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">background-color</span>:<span class="value"> <span class="hexcolor" style="color: rgb(0, 153, 153);">#f00</span>;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">transform</span>:<span class="value"> <span class="function">scale(<span class="number" style="color: rgb(0, 153, 153);">1</span>)</span> <span class="function">rotate(<span class="number" style="color: rgb(0, 153, 153);">0</span>deg)</span>;</span></span>
<span class="rule">}</span></span>
33% <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">background-color</span>:<span class="value"> <span class="hexcolor" style="color: rgb(0, 153, 153);">#00f</span>;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">-webkit-transform</span>:<span class="value"> <span class="function">scale(<span class="number" style="color: rgb(0, 153, 153);">1.1</span>)</span> <span class="function">rotate(-<span class="number" style="color: rgb(0, 153, 153);">5</span>deg)</span>;</span></span>
<span class="rule">}</span></span>
}
<span class="at_rule">@-o-keyframes pulse </span>{
0% <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">background-color</span>:<span class="value"> <span class="hexcolor" style="color: rgb(0, 153, 153);">#f00</span>;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">transform</span>:<span class="value"> <span class="function">scale(<span class="number" style="color: rgb(0, 153, 153);">1</span>)</span> <span class="function">rotate(<span class="number" style="color: rgb(0, 153, 153);">0</span>deg)</span>;</span></span>
<span class="rule">}</span></span>
33% <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">background-color</span>:<span class="value"> <span class="hexcolor" style="color: rgb(0, 153, 153);">#00f</span>;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">-webkit-transform</span>:<span class="value"> <span class="function">scale(<span class="number" style="color: rgb(0, 153, 153);">1.1</span>)</span> <span class="function">rotate(-<span class="number" style="color: rgb(0, 153, 153);">5</span>deg)</span>;</span></span>
<span class="rule">}</span></span>
}
<span class="at_rule">@keyframes pulse </span>{
0% <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">background-color</span>:<span class="value"> <span class="hexcolor" style="color: rgb(0, 153, 153);">#f00</span>;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">transform</span>:<span class="value"> <span class="function">scale(<span class="number" style="color: rgb(0, 153, 153);">1</span>)</span> <span class="function">rotate(<span class="number" style="color: rgb(0, 153, 153);">0</span>deg)</span>;</span></span>
<span class="rule">}</span></span>
33% <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">background-color</span>:<span class="value"> <span class="hexcolor" style="color: rgb(0, 153, 153);">#00f</span>;</span></span>
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">-webkit-transform</span>:<span class="value"> <span class="function">scale(<span class="number" style="color: rgb(0, 153, 153);">1.1</span>)</span> <span class="function">rotate(-<span class="number" style="color: rgb(0, 153, 153);">5</span>deg)</span>;</span></span>
<span class="rule">}</span></span>
}
</code></pre><h3 style="margin-bottom: 0.5em; font-family: inherit; line-height: 1.6em; color: inherit; text-rendering: optimizeLegibility; font-size: 18px; text-indent: 1em;">CSS字面量(CSS Literal)</h3><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">stylus</p><pre class="css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 0.75em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="at_rule">@css </span>{
<span class="tag" style="color: rgb(0, 0, 128);">body</span> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">font</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">14</span>px;</span></span>
<span class="rule">}</span></span>
}
</code></pre><p style="margin-bottom: 0.75em; line-height: 1.7em; text-indent: 1em;">编译成</p><pre class="css" style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 4px; margin-bottom: 0.75em; font-size: 12px; line-height: 1.5em; word-break: break-all; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); overflow-y: auto; background-color: rgb(246, 246, 246);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"><span class="tag" style="color: rgb(0, 0, 128);">css</span></code><span class="tag" style="color: rgb(0, 0, 128);"><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; color: rgb(51, 51, 51); border-radius: 3px; border: 0px; display: block; overflow-y: auto;">body</code></span><code style="padding: 0.3em; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; border-radius: 3px; border: 0px; display: block; overflow-y: auto;"> <span class="rules">{
<span class="rule"><span class="attribute" style="color: rgb(0, 128, 128);">font</span>:<span class="value"> <span class="number" style="color: rgb(0, 153, 153);">14</span>px;</span></span>
<span class="rule">}</span></span></code></pre></div></div><p></p>
页:
[1]