Home > Web Front-end > HTML Tutorial > compass安装教程 - Baiang

compass安装教程 - Baiang

WBOY
Release: 2016-05-21 08:54:36
Original
1589 people have browsed it

compass安装教程

compass和sass相当于,jquery和javascript,一个是封装的css库,另一个是javascript库,它们都目的是一样的,简化开发。

安装

一般来说,安装SASS的话,会自动帮助你安装compass。如果不确认是否有安装compass,在cmd中输入

<code>compass -v
</code>
Copy after login

显示 'compass' 不是内部或外部命令,也不是可运行的程序或批处理文件。代表未安装compass。

显示如下,那么安装成功。

D:\WEB\aaa\myproject>compass -v
Compass 1.0.3 (Polaris)
Copyright (c) 2008-2015 Chris Eppstein
Released under the MIT License.
Compass is charityware.
Please make a tax deductable donation for a worthy cause: http://umdf.org/compass
Copy after login

安装指令

gem update --system  #先更新gem
gem install compass  #安裝Compass
Copy after login

其它指令

<code>gem query –remote #卸载

md mycompass /# md 建立空文件夹
</code>
Copy after login

建立compass项目

cmd进入网站目录,在cmd中,输入以下指令。

<code>compass create myproject
</code>
Copy after login

myproject是项目的名字,执行后,会下载compass项目文件到指定目录下: - config.rb -> 配置文件 - .sass-cache -> 缓存文件 - sass -> sass文件 - stylesheets -> sass编译文件

cofing.rb 配置文件

http_path = "/" 
css_dir = "stylesheets"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "javascripts"

//可以外加指令
output_style = :compressed     //编译格式指定
Copy after login

编译文件

执行编译

<code>compass compile
</code>
Copy after login

只有在配置文件下,才能执行编译,不然会找不到.scss文件。

D:\WEB\aaa\mycompass\myproject\sass>compass compile
Compass can't find any Sass files to compile.
Is your compass configuration correct?.
If you're trying to start a new project, you have left off the directory argumen
t.
Run "compass -h" to get help.
Copy after login

在命令行模式下,除了一次性编译命令,compass还有自动编译命令

compass watch
Copy after login

结束自动编译按 CTRL + C,同样,也需要在配置文件下执行自动编译,才执行。

调用模块报错

如果调用模块报错,有可能是编码错误。

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template