Stylus是一款需要編譯的css語言,所以其本身文件不能被html直接調用,需要要編譯為css文件后再進行日常的加載。
stylus是一款優秀的css編譯語言,需要node.js支持,第一步需要安裝node.js
問題:Windows調試時ctrl+d無效果 ctrl+c退出? 怎樣直接在windows下輸出調試代碼
備注:# 代表本行是輸入回車運行行
1
# apt-get update # apt-get install -y python-software-properties software-properties-common # add-apt-repository ppa:chris-lea/node.js # apt-get update # apt-get install nodejs
2 node - v 查看node版本信息如果有返回信息則安裝成功
3 安裝stylus
# npm install stylus -g
注意:必須找-g 同時配置環境為全局方法
4 調試Stylus
# stylus
border-radius() -webkit-border-radius arguments -moz-border-radius arguments border-radius arguments body font 12px Helvetica, Arial, sans-serif a.button border-radius(5px)
輸入Ctrl+D調試返回結果
看看是否會返回
body { font: 12px Helvetica, Arial, sans-serif; } a.button { -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; }
5 styus文件的編譯
創建一個test.styl 的文件,文件內容如下:
1 border-radius() 2 -webkit-border-radius arguments 3 -moz-border-radius arguments 4 border-radius arguments 5 6 body 7 font 12px Helvetica, Arial, sans-serif 8 9 a.button 10 border-radius 5px
保存關閉,在命令行運行如下命令:
# stylus --compress < test.styl > test.css
看看是不是獲得一個test.css的文件,看看內容是否如下:
1 body{ 2 font:12px Helvetica,Arial,sans-serif 3 } 4 a.button{ 5 -webkit-border-radius:5px; 6 -moz-border-radius:5px; 7 border-radius:5px 8 }
這樣一個stylus的文件就被編譯成了html可以調用的css文件了。