CSSグラデーション完全ガイド:linear/radial/conicと高度な視覚効果の実践

開発ツール

CSSグラデーションの3種類

タイプ 構文 視覚効果
線形グラデーション linear-gradient() 直線方向に遷移
放射グラデーション radial-gradient() 中心から外側へ拡散
扇形グラデーション conic-gradient() 中心を軸に回転

線形グラデーション(linear-gradient)

基本構文

/* 方向 + カラーストップ */
background: linear-gradient(方向, ストップ1, ストップ2, ...);

/* 例 */
background: linear-gradient(to right, #667eea, #764ba2);
background: linear-gradient(135deg, #f093fb, #f5576c);
background: linear-gradient(to bottom right, #4facfe, #00f2fe);

方向パラメータ

/* キーワード指定 */
to top          /* 下から上へ */
to right        /* 左から右へ */
to bottom       /* 上から下へ(デフォルト) */
to left         /* 右から左へ */
to top right    /* 対角線 */

/* 角度指定(より精密) */
0deg    /* → to top */
90deg   /* → to right */
180deg  /* → to bottom */
45deg   /* → 右上の対角 */
135deg  /* → 右下の対角 */

カラーストップの制御

/* 等間隔配置(位置は自動計算) */
background: linear-gradient(red, yellow, green);
/* red: 0%, yellow: 50%, green: 100% */

/* 位置を指定 */
background: linear-gradient(red 0%, yellow 30%, green 100%);

/* ハードエッジ(遷移なし) */
background: linear-gradient(red 50%, blue 50%);

/* マルチセグメントグラデーション */
background: linear-gradient(
  red 0%, red 20%,
  yellow 20%, yellow 40%,
  green 40%, green 60%,
  blue 60%, blue 80%,
  purple 80%, purple 100%
);

放射グラデーション(radial-gradient)

基本構文

background: radial-gradient(形状 サイズ at 位置, ストップ...);

/* 例 */
background: radial-gradient(circle, #ff6b6b, #556270);
background: radial-gradient(ellipse at top, #ffd89b, #19547b);
background: radial-gradient(circle 100px at center, #fff, #000);

形状

circle    /* 円 */
ellipse   /* 楕円(デフォルト) */

サイズキーワード

closest-side     /* 最も近い辺まで */
farthest-side    /* 最も遠い辺まで */
closest-corner   /* 最も近い角まで */
farthest-corner  /* 最も遠い角まで(デフォルト) */

位置

at center           /* 中央(デフォルト) */
at top left         /* 左上 */
at 30% 70%          /* パーセント指定 */
at 100px 200px      /* ピクセル指定 */

扇形グラデーション(conic-gradient)

基本構文

background: conic-gradient(from 開始角度 at 位置, ストップ...);

/* 例 */
background: conic-gradient(red, yellow, green, blue, red);
background: conic-gradient(from 45deg, #f00, #0f0, #00f, #f00);

実践:円グラフ

.pie-chart {
  background: conic-gradient(
    #3b82f6 0% 35%,
    #ef4444 35% 55%,
    #22c55e 55% 80%,
    #f59e0b 80% 100%
  );
  border-radius: 50%;
}

実践:カラーホイール

.color-wheel {
  background: conic-gradient(
    hsl(0, 100%, 50%),
    hsl(60, 100%, 50%),
    hsl(120, 100%, 50%),
    hsl(180, 100%, 50%),
    hsl(240, 100%, 50%),
    hsl(300, 100%, 50%),
    hsl(360, 100%, 50%)
  );
  border-radius: 50%;
}

高度な視覚効果

1. グラデーションの重ね合わせ(複数レイヤー)

.multi-gradient {
  background:
    linear-gradient(217deg, rgba(255,0,0,.8), rgba(255,0,0,0) 70.71%),
    linear-gradient(127deg, rgba(0,255,0,.8), rgba(0,255,0,0) 70.71%),
    linear-gradient(336deg, rgba(0,0,255,.8), rgba(0,0,255,0) 70.71%);
}

2. グリッド背景

.grid-bg {
  background:
    linear-gradient(rgba(0,0,0,0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.1) 1px, transparent 1px);
  background-size: 20px 20px;
}

3. ドット背景

.dot-bg {
  background: radial-gradient(circle 2px, #999 100%, transparent 100%);
  background-size: 20px 20px;
}

4. 光沢エフェクト(Shine Effect)

.shine-button {
  position: relative;
  overflow: hidden;
  background: #3b82f6;
}

.shine-button::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(255,255,255,0.4) 45%,
    rgba(255,255,255,0.4) 55%,
    transparent 60%
  );
  animation: shine 3s infinite;
}

@keyframes shine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

5. グラスモーフィズム(Glassmorphism)

.glass-card {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.05)
  );
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
}

6. グラデーションテキスト

.gradient-text {
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

7. グラデーションボーダー

.gradient-border {
  position: relative;
  background: #1f2937;
  border-radius: 12px;
}

.gradient-border::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, #667eea, #764ba2, #f093fb);
  border-radius: 14px;
  z-index: -1;
}

8. アニメーショングラデーション

.animated-gradient {
  background: linear-gradient(
    -45deg,
    #ee7752, #e73c7e, #23a6d5, #23d5ab
  );
  background-size: 400% 400%;
  animation: gradient-shift 8s ease infinite;
}

@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

繰り返しグラデーション

/* 繰り返し線形グラデーション → ストライプ */
.repeating-linear {
  background: repeating-linear-gradient(
    45deg,
    #3b82f6,
    #3b82f6 10px,
    #60a5fa 10px,
    #60a5fa 20px
  );
}

/* 繰り返し放射グラデーション → 的(ターゲット) */
.repeating-radial {
  background: repeating-radial-gradient(
    circle,
    #3b82f6,
    #3b82f6 10px,
    #60a5fa 10px,
    #60a5fa 20px
  );
}

/* 繰り返し扇形グラデーション → レーダー */
.repeating-conic {
  background: repeating-conic-gradient(
    #3b82f6 0deg 30deg,
    #60a5fa 30deg 60deg
  );
}

ToolsKuグラデーションジェネレーターを使う

  1. CSSグラデーションジェネレーターを開く
  2. グラデーションタイプ(linear/radial/conic)を選択
  3. カラーストップを追加し、位置と色を調整
  4. 方向/角度を調整
  5. リアルタイムで効果をプレビュー
  6. 生成されたCSSコードをコピー

グラデーションのパフォーマンス最適化

テクニック 説明
カラーストップを増やしすぎない 3〜5個が最適、8個を超えると描画に影響
rgbaよりhexを優先 #ff000080 は rgba(255,0,0,0.5) より短い
グラデーション領域は小さく 大面積のグラデーションは描画コストが増大
アニメーションはbackground-positionで カラーストップの値をアニメーションさせない
will-change: background アニメーションするグラデーションにヒントを追加

ブラウザ対応状況

機能 Chrome Firefox Safari
linear-gradient ✅ すべて ✅ すべて ✅ すべて
radial-gradient ✅ すべて ✅ すべて ✅ すべて
conic-gradient 69+ 83+ 12.1+
repeating-conic-gradient 69+ 83+ 12.1+
複数グラデーション ✅ すべて ✅ すべて ✅ すべて
background-clip: text ✅ 49+ ✅

まとめ

CSSグラデーションはビジュアルデザインの万能ナイフです。シンプルな2色の遷移から、複雑なグリッド背景、光沢エフェクト、グラスモーフィズムまで、グラデーションですべてこなせます。linear/radial/conicの3タイプ + カラーストップ制御 + 複数レイヤーの重ね合わせをマスターすれば、ほとんどの視覚効果を実現できます。ToolsKuのグラデーションジェネレーターなら、パラメータを視覚的に調整して、ワンクリックでCSSコードをコピーできます。

#CSS渐变#渐变生成器#设计工具#UI设计#教程