Toolypet
ブログに戻る
CSS

CSSグラデーション完全ガイド2026 - 線形からメッシュまですべて

linear-gradient、radial-gradient、conic-gradientのすべて。実践例とともに学ぶCSSグラデーションマスターガイドです。

Toolypet Team

Toolypet Team

Development Team

6 分で読めます

CSSグラデーション完全ガイド

グラデーションは、モダンウェブデザインで最も多く使用されるCSSエフェクトの一つです。Instagram、Stripe、Spotify...すべてグラデーションでブランドアイデンティティを表現しています。

このガイドでは、CSSグラデーションのすべての種類と実践的な活用法をコード例とともに解説します。


グラデーションの基本理解

グラデーションの種類

種類関数説明
線形linear-gradient()直線方向の遷移
放射状radial-gradient()中心から外側へ
円錐形conic-gradient()中心基準の回転
繰り返しrepeating-*-gradient()パターンの繰り返し

基本構文

.element {
  background: linear-gradient(direction, color1, color2, ...);
}

Linear Gradient: 線形グラデーション

方向の設定

/* キーワード方向 */
.to-right { background: linear-gradient(to right, #6366f1, #8b5cf6); }
.to-bottom { background: linear-gradient(to bottom, #6366f1, #8b5cf6); }
.to-top-right { background: linear-gradient(to top right, #6366f1, #8b5cf6); }

/* 角度方向 */
.angle-45 { background: linear-gradient(45deg, #6366f1, #8b5cf6); }
.angle-90 { background: linear-gradient(90deg, #6366f1, #8b5cf6); }
.angle-180 { background: linear-gradient(180deg, #6366f1, #8b5cf6); }

方向キーワードまとめ

キーワード角度方向
to top0deg
to right90deg
to bottom180deg
to left270deg
to top right45deg

カラーストップ

/* 均等分布(自動) */
.auto {
  background: linear-gradient(#ff0000, #00ff00, #0000ff);
  /* 0%, 50%, 100% */
}

/* 明示的な位置 */
.explicit {
  background: linear-gradient(
    #ff0000 0%,
    #ff0000 30%,    /* 0-30%: 赤を維持 */
    #00ff00 30%,    /* 30%で急激に変換 */
    #00ff00 70%,    /* 30-70%: 緑を維持 */
    #0000ff 70%     /* 70%で急激に変換 */
  );
}

/* ハードストップ(急激な遷移) */
.hard-stop {
  background: linear-gradient(
    #6366f1 50%,
    #8b5cf6 50%
  );
}

実践例: トレンドグラデーション

/* Instagramスタイル */
.instagram {
  background: linear-gradient(
    45deg,
    #f09433 0%,
    #e6683c 25%,
    #dc2743 50%,
    #cc2366 75%,
    #bc1888 100%
  );
}

/* Stripeスタイル */
.stripe {
  background: linear-gradient(
    135deg,
    #667eea 0%,
    #764ba2 100%
  );
}

/* グラスモーフィズム背景 */
.glassmorphism {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.05)
  );
  backdrop-filter: blur(10px);
}

Radial Gradient: 放射状グラデーション

基本構文

.radial {
  background: radial-gradient(shape size at position, color1, color2, ...);
}

形状(Shape)

/* 円形 */
.circle {
  background: radial-gradient(circle, #6366f1, #8b5cf6);
}

/* 楕円形(デフォルト) */
.ellipse {
  background: radial-gradient(ellipse, #6366f1, #8b5cf6);
}

サイズ(Size)

キーワード説明
closest-side最も近い辺まで
farthest-side最も遠い辺まで
closest-corner最も近い角まで
farthest-corner最も遠い角まで(デフォルト)
.size-demo {
  background: radial-gradient(circle closest-side at 30% 30%, #6366f1, #8b5cf6);
}

位置(Position)

/* キーワード位置 */
.top-left {
  background: radial-gradient(circle at top left, #6366f1, #8b5cf6);
}

/* パーセント位置 */
.percent {
  background: radial-gradient(circle at 30% 70%, #6366f1, #8b5cf6);
}

/* ピクセル位置 */
.pixel {
  background: radial-gradient(circle at 100px 50px, #6366f1, #8b5cf6);
}

実践例: スポットライトエフェクト

.spotlight {
  background:
    radial-gradient(
      circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
      rgba(99, 102, 241, 0.3) 0%,
      transparent 50%
    ),
    #1a1a2e;
}
// マウスに追従するスポットライト
document.addEventListener('mousemove', (e) => {
  const x = (e.clientX / window.innerWidth) * 100;
  const y = (e.clientY / window.innerHeight) * 100;
  document.documentElement.style.setProperty('--mouse-x', `${x}%`);
  document.documentElement.style.setProperty('--mouse-y', `${y}%`);
});

Conic Gradient: 円錐形グラデーション

基本構文

.conic {
  background: conic-gradient(from angle at position, color1, color2, ...);
}

基本例

/* カラーホイール */
.color-wheel {
  background: conic-gradient(
    red, yellow, lime, aqua, blue, magenta, red
  );
  border-radius: 50%;
}

/* パイチャート */
.pie-chart {
  background: conic-gradient(
    #6366f1 0deg 90deg,      /* 25% */
    #8b5cf6 90deg 180deg,    /* 25% */
    #a78bfa 180deg 270deg,   /* 25% */
    #c4b5fd 270deg 360deg    /* 25% */
  );
  border-radius: 50%;
}

開始角度と位置

/* 開始角度の変更 */
.from-angle {
  background: conic-gradient(
    from 45deg,
    #6366f1, #8b5cf6
  );
}

/* 中心位置の変更 */
.at-position {
  background: conic-gradient(
    at 30% 70%,
    #6366f1, #8b5cf6
  );
}

実践例: ドーナツチャート

.donut-chart {
  background: conic-gradient(
    #6366f1 0deg 120deg,
    #8b5cf6 120deg 240deg,
    #a78bfa 240deg 360deg
  );
  border-radius: 50%;
  position: relative;
}

.donut-chart::after {
  content: '';
  position: absolute;
  inset: 25%;
  background: white;
  border-radius: 50%;
}

Repeating Gradients: 繰り返しパターン

繰り返し線形

/* ストライプパターン */
.stripes {
  background: repeating-linear-gradient(
    45deg,
    #6366f1,
    #6366f1 10px,
    #8b5cf6 10px,
    #8b5cf6 20px
  );
}

/* 警告テープ */
.warning-tape {
  background: repeating-linear-gradient(
    45deg,
    #fbbf24,
    #fbbf24 20px,
    #1f2937 20px,
    #1f2937 40px
  );
}

繰り返し放射状

/* 波紋パターン */
.ripple {
  background: repeating-radial-gradient(
    circle at center,
    #6366f1 0px,
    #6366f1 5px,
    transparent 5px,
    transparent 20px
  );
}

繰り返し円錐形

/* 扇形パターン */
.fan {
  background: repeating-conic-gradient(
    #6366f1 0deg 10deg,
    #8b5cf6 10deg 20deg
  );
}

複数グラデーションレイヤー

レイヤーの重ね合わせ

.layered {
  background:
    linear-gradient(45deg, rgba(99, 102, 241, 0.5), transparent 50%),
    linear-gradient(-45deg, rgba(139, 92, 246, 0.5), transparent 50%),
    linear-gradient(to bottom, #1a1a2e, #16213e);
}

グラデーション + 画像

.overlay {
  background:
    linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.1),
      rgba(0, 0, 0, 0.8)
    ),
    url('/image.jpg') center/cover;
}

実践例: メッシュグラデーションエフェクト

.mesh-gradient {
  background:
    radial-gradient(at 40% 20%, #6366f1 0px, transparent 50%),
    radial-gradient(at 80% 0%, #8b5cf6 0px, transparent 50%),
    radial-gradient(at 0% 50%, #a78bfa 0px, transparent 50%),
    radial-gradient(at 80% 50%, #c4b5fd 0px, transparent 50%),
    radial-gradient(at 0% 100%, #e9d5ff 0px, transparent 50%),
    radial-gradient(at 80% 100%, #fae8ff 0px, transparent 50%),
    #1e1b4b;
}

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

位置アニメーション

.animated-gradient {
  background: linear-gradient(
    270deg,
    #6366f1,
    #8b5cf6,
    #a78bfa,
    #c4b5fd
  );
  background-size: 400% 400%;
  animation: gradient-shift 15s ease infinite;
}

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

Hue Rotateアニメーション

.hue-rotate {
  background: linear-gradient(45deg, #6366f1, #8b5cf6);
  animation: hue-rotate 5s linear infinite;
}

@keyframes hue-rotate {
  to { filter: hue-rotate(360deg); }
}

@propertyを使ったスムーズな色遷移

@property --gradient-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

.smooth-rotate {
  --gradient-angle: 0deg;
  background: conic-gradient(
    from var(--gradient-angle),
    #6366f1, #8b5cf6, #6366f1
  );
  animation: rotate-gradient 3s linear infinite;
}

@keyframes rotate-gradient {
  to { --gradient-angle: 360deg; }
}

グラデーションテキスト

基本実装

.gradient-text {
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

アニメーションテキスト

.animated-text {
  background: linear-gradient(
    90deg,
    #6366f1,
    #8b5cf6,
    #a78bfa,
    #6366f1
  );
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: text-shine 3s linear infinite;
}

@keyframes text-shine {
  to { background-position: 300% 0; }
}

グラデーションボーダー

clip-path方式

.gradient-border {
  position: relative;
  background: white;
  padding: 2rem;
}

.gradient-border::before {
  content: '';
  position: absolute;
  inset: 0;
  padding: 3px;
  background: linear-gradient(45deg, #6366f1, #8b5cf6);
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  border-radius: inherit;
}

border-image方式

.gradient-border-simple {
  border: 3px solid;
  border-image: linear-gradient(45deg, #6366f1, #8b5cf6) 1;
}

パフォーマンス最適化

GPU アクセラレーションの活用

/* transformでアニメーション */
.optimized {
  background: linear-gradient(45deg, #6366f1, #8b5cf6);
  transform: translateZ(0); /* GPUレイヤーを作成 */
}

複雑なグラデーションの代替

/* 多くのレイヤーの代わりに画像を使用検討 */
.complex {
  background: url('/gradient.webp') center/cover;
}

FAQ

Q1: グラデーションの色選びが難しいです。おすすめの組み合わせはありますか?

A: Gradient Generatorで人気のグラデーションプリセットをご確認ください。また、同じ色系(紫-青、オレンジ-ピンク)から始めると自然に見えます。

Q2: IEでグラデーションは動作しますか?

A: IE11はlinear-gradientradial-gradientをサポートしていますが、conic-gradientはサポートしていません。2026年現在、IEサポートはほぼ終了しています。

Q3: グラデーションはバンドルサイズに影響しますか?

A: CSSグラデーションは画像よりもはるかに軽量です。複雑なグラデーションでも数行のCSSで表現されるため、バンドルサイズへの影響は微小です。

Q4: グラデーションの透明度はどう設定しますか?

A: rgba()またはhsla()を使用してください。

background: linear-gradient(rgba(99, 102, 241, 0.5), rgba(139, 92, 246, 0.5));

Q5: グラデーションアニメーションがカクつきます。

A: background-positionアニメーションの代わりに、@propertyでCSS変数をアニメーションさせるとよりスムーズになります。またはfilter: hue-rotate()を使用してください。


まとめ

CSSグラデーションの要点:

  1. Linear: 方向 + カラーストップ
  2. Radial: 形状 + サイズ + 位置
  3. Conic: 回転角度 + 位置
  4. 複数レイヤー: カンマで区切り、上から下に重なる
  5. アニメーション: background-positionまたは@property

関連ツール

ツール用途
Gradient Generatorグラデーションの生成とプレビュー
Box-Shadow Generatorシャドウエフェクトの生成
Filter EditorCSSフィルターエフェクト
CSSグラデーションGradientデザインウェブデザインCSS3

著者について

Toolypet Team

Toolypet Team

Development Team

The Toolypet Team creates free, privacy-focused web tools for developers and designers. All tools run entirely in your browser with no data sent to servers.

Web DevelopmentCSS ToolsDeveloper ToolsSEOSecurity