webstorm配置compass

1、compass安装

compass与sass配合写css很方便,也很简单,避免了一些变量和浏览器的兼容问题。安装compass与sass一样,命令行输入gem install compass即可。

创建一个新的compass工程,命令行输入compass create newproject。在生成的工程中,分类有images、sass、stylesheets和config.rb。config.rb中指定了sass和css的目录。


2、webstorm配置

webstorm->File->Setting中增加对compass scss的支持,如下图所示:


设置对compass 的默认支持,如下图:


指向工程目录中的config.rb。

这里有个疑问,config.rb中有个css_dir输出目录,在File Watchers中也有个输出文件目录,这两者目前还不清楚,大家自行试试。

这里我们可以试试compass的写法了,例如在默认生成的文件ie.css中:

@import "compass/css3";
$blue : #0000ff;

#border-radius {
  @include border-radius(25px);
}

div {
  background-color: $blue;
  @include border-radius(5px);
}

p {
  background-color: $blue;
}
,然后保存后会自动生成为:

#border-radius {
  -moz-border-radius: 25px;
  -webkit-border-radius: 25px;
  border-radius: 25px;
}

/* line 13, ../live/sass/ie.scss */
div {
  background-color: #0000ff;
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;
  border-radius: 5px;
}

/* line 18, ../live/sass/ie.scss */
p {
  background-color: #0000ff;
}
可以看到@include border-radius(25px); 变成了
-moz-border-radius: 25px;
  -webkit-border-radius: 25px;

是不是很方便。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值