stylus , another css processor

zyip發表於2015-03-25

 

1. install from npm

sudo npm install stylus 

 

2. create a styl file named step1.styl

border-radius() {
  -webkit-border-radius: arguments
  -moz-border-radius: arguments
  border-radius: arguments
}

body a {
  font: 12px/1.4 "Lucida Grande", Arial, sans-serif;
  background: black;
  color: #ccc;
}

form input {
  padding: 5px;
  border: 1px solid;
  border-radius: 5px;
}

 

3. create a js file for render css from styl file

var stylus = require('stylus');


var str=".{border:1px solid red;}";
str = require("fs").readFileSync("step1.styl", "utf8");

stylus.render(str, { filename: 'step1.styl' }, function(err, css){
  if (err) throw err;
  console.log(css);
});

 

 

 

https://github.com/Automattic/stylus

 

相關文章