CSS3のマルチカラムレイアウト:column-countプロパティの使い方
CSS3のマルチカラムレイアウトにおけるcolumn-countプロパティは、要素の内容を何列に分割して表示するかを指定するためのプロパティです。新聞や雑誌のような段組みレイアウトを、HTMLの複雑な構造を組むことなく簡単に実現できます。
このプロパティを使うことで、テキストが自動的に指定した列数に分割され、ブラウザが内容量に応じて各列の高さを調整してくれます。
column-countプロパティの実装例
以下のコードを実行すると、CSSでcolumn-countプロパティを実装した動作を確認できます。
<html>
<head>
<style>
.multi {
/* 列数を指定 */
-webkit-column-count: 4;
-moz-column-count: 4;
column-count: 4;
/* 列間の余白を指定 */
-webkit-column-gap: 40px;
-moz-column-gap: 40px;
column-gap: 40px;
/* 列間の区切り線スタイルを指定 */
-webkit-column-rule-style: solid;
-moz-column-rule-style: solid;
column-rule-style: solid;
}
</style>
</head>
<body>
<div class = "multi">
Tutorials Point originated from the idea that there exists a class of readers who respond
better to online content and prefer to learn new skills at their own pace from the comforts
of their drawing rooms. The journey commenced with a single tutorial on HTML in 2006 and
elated by the response it generated, we worked our way to adding fresh tutorials to our
repository which now proudly flaunts a wealth of tutorials and allied articles on topics
ranging from programming languages to web designing to academics and much more.
</div>
</body>
</html>
コードのポイント解説
- column-count: 4; … 要素の内容を4列に分割して表示します。
- column-gap: 40px; … 各列の間に40pxの余白(ギャップ)を設けます。
- column-rule-style: solid; … 列と列の間に実線の区切り線を引きます。
- -webkit- や -moz- の接頭辞は、古いバージョンのChrome・Safari・Firefoxなどに対応させるためのベンダープレフィックスです。
なお、column-countで列数を固定する代わりに、column-widthプロパティを使えば「最低限確保したい列幅」を指定でき、画面サイズに応じてブラウザが自動的に列数を調整することも可能です。レスポンシブデザインではこちらの方法が便利です。
表示結果

-
CSS3マルチカラムのcolumn-ruleプロパティの使い方
CSS3のマルチカラムレイアウトにおけるcolumn-ruleプロパティは、複数のカラム(段組み)の間に表示される罫線(区切り線)のスタイルを指定するためのプロパティです。column-ruleはショートハンド(一括指定)プロパティであり、以下の3つの個別プロパティをまとめて設定できます。column-rule-width:罫線の太さ(pxなど)column-rule-style:罫線の種類(solid、dotted、dashed、doubleなど)column-rule-color:罫線の色例えば「column-rule: 4px solid #ff00ff;」と記述すれば、「4pxの太さ」
-
CSS3のtransitionショートハンド(短縮)プロパティの使い方
CSSのtransitionショートハンド(短縮)プロパティを使うと、transition-property(遷移対象のプロパティ)、transition-duration(遷移にかかる時間)、transition-timing-function(変化の速度カーブ)、transition-delay(遅延時間)という4つの個別プロパティを、たった1行にまとめて指定することができます。値は「プロパティ名 → 時間 → タイミング関数 → 遅延」の順にスペース区切りで記述します。複数のプロパティを同時にアニメーションさせたい場合は、それぞれの指定をカンマ(,)で区切って並べます。記述例以下は、tr