[CSS]CSS3グラデーションの表示サンプルと指定方法のまとめ

現在、Firefox, Safari, Chromeで利用できるCSS3グラデーションの表示サンプルと指定方法のまとめをDynamic Driveから紹介します。

サイトのキャプチャ

CSS Library:CSS3 Linear Gradients

下記は各ポイントをピックアップしたものです。

CSS3グラデーションの基礎知識

CSS3グラデーションをサポートしているブラウザは現在のところ、下記の三つです。

  • Firefox 3.6+
  • Safari 2+
  • Chrome

CSS3グラデーションの対応エレメントは、下記の二つです。

  • background
  • background-image

CSS3グラデーションの指定方法はmoz系(Firefox)とwebkit系(Safari, Chrome)で異なり、下記のようになります。

moz系

-moz-linear-gradient(
 || , color-stops)

webkit系

-webkit-gradient(linear,
, color-stops)

表示サンプルと指定方法

デモのキャプチャ

左から右へのグラデーション

background: -moz-linear-gradient(left, #00abeb, #fff);
background: -webkit-gradient(linear, left center, right center, from(#00abeb), to(#fff));
デモのキャプチャ

右から左へのグラデーション

background: -moz-linear-gradient(right, #00abeb, #fff);
background: -webkit-gradient(linear, right center, left center, from(#00abeb), to(#fff));
デモのキャプチャ

上から下へのグラデーション

background: -moz-linear-gradient(top, #00abeb, #fff);
background: -webkit-gradient(linear, center top, center bottom, from(#00abeb), to(#fff));
デモのキャプチャ

下から上へのグラデーション

background: -moz-linear-gradient(bottom, #00abeb, #fff);
background: -webkit-gradient(linear, center bottom, center top, from(#00abeb), to(#fff));
デモのキャプチャ

左上から右下へのグラデーション

background: -moz-linear-gradient(left top 315deg, #00abeb, #fff);
background: -webkit-gradient(linear, left top, right bottom, from(#00abeb), to(#fff));
デモのキャプチャ

右上から左下へのグラデーション

background: -moz-linear-gradient(right top 225deg, #00abeb, #fff);
background: -webkit-gradient(linear, right top, left bottom, from(#00abeb), to(#fff));
デモのキャプチャ

左から右へのグラデーションで途中でとめる

background: -moz-linear-gradient(left, #00abeb, #fff 45%);
background: -webkit-gradient(linear, left center, right center, from(#00abeb), color-stop(45%, #fff));
デモのキャプチャ

左上からオレンジ・イエロー・ホワイトのグラデーション

background: -moz-linear-gradient(left top 315deg, orange, yellow 30%, white 40%);
background: -webkit-gradient(linear, left top, right bottom, from(orange), color-stop(30%, yellow), color-stop(40%, white));
デモのキャプチャ

暗いブルーと明るいブルーと中間のブルーを均等にフェードさせるグラデーション

background: -moz-linear-gradient(center top, #b8d8f2, #92bde0 25%, #3282c2 50%, #92bde0 75%, #b8d8f2);
background: -webkit-gradient(linear, center top, center bottom, from(#b8d8f2), color-stop(25%, #92bde0), color-stop(50%, #3282c2), color-stop(75%, #92bde0), to(#b8d8f2));
デモのキャプチャ

7色のレインボーカラーのグラデーション

background: -moz-linear-gradient(left, red, orange, yellow, green, blue, indigo, violet);
background: -webkit-gradient(linear, left center, right center, from(red), color-stop(14%, orange), color-stop(28%, yellow), color-stop(42%, green), color-stop(56%, blue), color-stop(70%, indigo), to(violet));

top of page

Trackback

leave your Comments

※承認制のため、即時には反映されません。
※匿名、通りすがりさんなどへの回答は控えさせていただきます。

Comments

10時のヘッドライン | CROSS SBM

on 2010年3月18日

[...] – IDEA*IDEA ~ 百式管理人のライフハックブログはてブ:8 fc2:1 [CSS]CSS3グラデーションの表示サンプルと指定方法のまとめ | コリスはてブ:12 [...]

14時のヘッドライン | CROSS SBM

on 2010年3月18日

[...] : ドコモ スマートフォン Xperia(TM)を発売 | お知らせ | NTTドコモはてブ:5 [CSS]CSS3グラデーションの表示サンプルと指定方法のまとめ | コリスlivedoor:3 リンジー・ローハン、新恋人は男性です。newsing:1 [...]

freewebdev.jp

on 2010年3月18日

CSS3グラデーションの表示サンプルと指定方法のまとめ

「CSS Library:CSS3 Linear Gradients」
CSS3のプロパティの一つである linear-gradient(背景のグラデーション)の表示サンプルと指定方法のまとめです。
単純な物から、虹のようなやや複雑なグラデーシ…

top of page

©2011 coliss