compassのミックスイン
compassの魅力のひとつは豊富で実績のあるミックスインが使えることです。ここではcompassコアに含まれるミックスインの概要を紹介します。まず詳しいことは以下の公式リファレンスをご覧ください。英語ではありますが具体的なコード例もでているので、制作の際には重宝するでしょう。
css3関連
css3を使うためには現状では -moz- や -webkit- などのベンダープレフィックスを記述しなければなりません。compassではその手間を軽減して簡単にクロスブラウザを実現することができるミックスインが用意されています。display:inline-blockなど古いブラウザの互換性に注意しなければならないプロパティもサポートされているので、とても助かります。

- Appearance – Specify the CSS3 appearance property.
 - Background Clip – Specify the background clip for all browsers.
 - Background Origin – Specify the background origin for all browsers.
 - Background Size – Specify the background size for all browsers.
 - Border Radius – Specify the border radius for all browsers.
 - Box – This module provides mixins that pertain to the CSS3 Flexible Box.
 - Box Shadow – Specify the box shadow for all browsers.
 - Box Sizing – Specify the box sizing for all browsers.
 - Columns – Specify a columnar layout for all browsers.
 - Filter – Specify the (image) filter for all browsers.
 - Font Face – Specify a downloadable font face for all browsers.
 - Hyphenation – Mixin for breaking space and injecting hypens into overflowing text
 - Images – Specify linear gradients and radial gradients for many browsers.
 - Inline Block – Declare an element inline block for all browsers.
 - Opacity – Specify the opacity for all browsers.
 - CSS Regions – Specify CSS Regions for supported browsers.
 - Text Shadow – Specify the text shadow for all browsers.
 - Transform – Specify transformations for many browsers.
 - Transition – Specify a style transition for all browsers.
 - User Interface – Declare an element inline block for all browsers.
 
レイアウト関連
ページレイアウトをサポートするミックスインです。フッタ領域をウィンドウ下部にはりつけるSticky Footerや子要素を親要素全体に拡張するStretchingなどが用意されています。

- Grid Background
 - Sticky Footer
 - Stretching
 
リセット関連
いわゆるcssリセットを行うミックスインです。最近ではcssリセットをせずにブラウザスタイルを生かしたデザインも多いですが、compassミックスインの中にはリセットを前提としたものも存在しますので、compassでの製作の際はcssリセットを行う方がいいようです。

- global-reset
Based on Eric Meyer's reset 2.0 Global reset rules. For more specific resets, use the reset mixins provided below - nested-reset
Reset all elements within some selector scope. To reset the selector itself, mixin the appropriate reset mixin for that element type as well. This could be useful if you want to style a part of your page in a dramatically different way. - reset-box-model
Reset the box model measurements. - reset-font
Reset the font and vertical alignment. - reset-focus
Resets the outline when focus. For accessibility you need to apply some styling in its place. - reset-body
Reset a body element. - reset-list-style
Reset the list style of an element. - reset-table
Reset a table - reset-table-cell
Reset a table cell (th, td) - reset-quotation
Reset a quotation (q, blockquote) - reset-image-anchor-border
Resets the border. - reset-html5
Unrecognized elements are displayed inline. This reset provides a basic reset for block html5 elements so they are rendered correctly in browsers that don't recognize them and reset in browsers that have default styles for them. - reset-display($selector, $important)
 
タイポグラフィ
基本的なテキストのスタイリングを行うミックスインで以下のものが含まれます。
- Links リンク(<a>タグ)のスタイリングを行います。hover時にアンダーラインを表示するHover Link、:active、:hoverなどに対応する色を指定するLink colors、リンクのスタイルを消去するUnstyled Linkがあります。
たとえば今流行りの「親要素全体に広がったリンク」はUnstyled LinkでリセットしてからStrechingを使えば、簡単につくることができるでしょう。 - Lists リスト(<ul>など)のスタイリングを行います。リストバレットをコントロールするBullets、水平に並んだHorizontal ListやInline Block List、Inline Listがあります。
 - Text おおざっぱなカテゴリですが、含まれるミックスインはかなり有用なものばかりです。テキストがはみ出たときに省略マークを表示するEllipsis、折り返しをコントロールするForce Wrap、No Wrap、タイトルなどのテキストを画像の置き換えるText Replacementがあります。
 - Vertical Rhythm 基準となるライン高を決め、それに沿って縦方向のレイアウトをコントロールするミックスインです。整合性の取れた行送りや文字・ライン高の計算などをサポートしています。横方向のレイアウト整合性をとるのがBlueprintなどのグリッドシステムだとすると、Vertical Rhythmは縦方向を担当します。詳しいことは別のページで説明をします。
 

- Links – Tools for styling anchor links.
 - Lists – Tools for styling lists.
 - Text – Style helpers for your text.
 - Vertical Rhythm – Create and maintain a vertical rhythm for your type.
 
ヘルパー
さまざまなヘルパー関数です。一般的な三角関数などの他、色を扱う関数、画像サイズを返す関数などcss独自の便利な関数が用意されています。

- adjust-lightness()
 - adjust-saturation()
 - append-selector()
 - color-stops()
 - cos()
 - css2-fallback()
 - e()
 - elements-of-type()
 - enumerate()
 - font-files()
 - font-url()
 - headings()
 - image-width()
 - image-height()
 - image-url()
 - inline-font-files()
 - inline-image()
 - logarithm()
 - nest()
 - pow()
 - prefix()
 - prefixed()
 - pi()
 - sin()
 - sqrt()
 - stylesheet-url()
 - scale-lightness()
 - shade()
 - tan()
 - tint()
 - -css2()
 - -moz()
 - -ms()
 - -o()
 - -pie()
 - -svg()
 - -webkit()
 
ユーティリティ
コントラストのある色を計算してくれるContrastedや画像スプライトを扱うSprites、テーブルを扱うTablesなど、さまざまなユーティリティが含まれます。

- Links – Tools for styling anchor links.
 - Lists – Tools for styling lists.
 - Text – Style helpers for your text.
 - Color – Utilities for working with colors.
 - General – Generally useful utilities that don't fit elsewhere.
 - Sprites – Sprite mixins.
 - Tables – Style helpers for your tables.
 
以上がcompassのコアを構成するミックスインですが、このほかにBlueprintというグリッドシステムフレームワークが含まれています。これについては別のページで説明をしています。
            
Web開発のとき統合開発環境としてEclipse(あるいはAptanaStudio)を使用している人は多いでしょう。ここではEclipseのビルドシステムを使ってcompassをコンパイルする方法を説明します。
最近のWebデザインではメディアクエリを使用したレスポンシブデザインが必須となっています。sassでももちろんメディアクエリはサポートされています。sassならではの拡張がされているので複雑になりがちなメディアクエリもスッキリと書けるようになります。
cssでは背景に画像を指定することが良くあります。普通はbackground-image: url(../images/bg.png); のように書くことでしょう。しかしこの方法ではフォルダレイアウトを変更すると、すべての指定を書き換えなければなりませんし、CMSではこのような相対指定が使えない場合もあります。このような不便を解消するためにcompassでは画像を特別な方法であつかいます。
横方向のレイアウト整合性をとるのがBlueprintなら、縦方向(行間)をコントロールするのがVertical Rhythmです。Blueprintにも行間コントロールの機能はあるのですがあまり使いやすいとは言えません。ここではcompassコアに含まれるVertical Rhythmの使い方を説明します。
sassは従来のcssと互換性のあるスタイルシート言語です。実際、cssファイルの拡張子をscssに変えただけでも立派なsassソースファイルであり、コンパイルをすることができます。なのでcssについての知識があればsassは簡単に覚えることができます。ここではその概要を説明します。
compassを利用するにはまずcompassコンパイラをインストールする必要があります。ここではWindows環境にcompassをインストールする方法と、基本的な利用方法について説明をします。
Webページを作成するとき、作業の半分はグラフィックの制作に、残りの半分はCSSの制作に費やされるでしょう。CSSの制作環境は数年前と比べて格段に良くなっているとはいえ、CSSという言語自体はそれほど進歩していません。特にDrupalなどのCMSプロジェクトではセレクタの記述がどんどん長くなる傾向にあり、そのためcssコードの共有や保守がますます難しくなってきています。