回転グラデーションボーダー
@property で角度を回転させた conic-gradient のボーダーがカードの縁を発光させる演出。価格表やバッジカードに使えます。
ライブデモ
使用例(お題: アイドルグループ Sakura)
この技法を「アイドルグループ Sakura」というテーマのダミーサイトで実際に使った例です。
HTML
<!-- Sakura:回転グラデボーダーで縁を発光させるメンバーカード -->
<section class="sg-stage">
<header class="sg-head">
<span class="sg-eyebrow">MEMBER</span>
<h1 class="sg-title">桜のメンバー</h1>
</header>
<div class="sg-cards">
<!-- ★主役:縁が回転発光するメンバーカード -->
<article class="sg-card">
<div class="sg-card__photo" style="--n:71"></div>
<span class="sg-card__color" style="--c:#ff8fb3">桜ピンク</span>
<h2 class="sg-card__name">花村 みお</h2>
<p class="sg-card__role">センター / リードボーカル</p>
</article>
<article class="sg-card">
<div class="sg-card__photo" style="--n:72"></div>
<span class="sg-card__color" style="--c:#b39cff">ラベンダー</span>
<h2 class="sg-card__name">星野 あかり</h2>
<p class="sg-card__role">ダンス / ラップ</p>
</article>
<article class="sg-card">
<div class="sg-card__photo" style="--n:73"></div>
<span class="sg-card__color" style="--c:#7fd6ff">スカイ</span>
<h2 class="sg-card__name">小川 ゆい</h2>
<p class="sg-card__role">サブボーカル / MC</p>
</article>
</div>
</section>
CSS
/* Sakura:淡い背景に、縁が回転発光するメンバーカード */
@property --sg-angle {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
.sg-stage {
min-height: 400px;
height: 400px;
overflow: hidden;
padding: 24px 26px;
background: linear-gradient(160deg, #fff5f9 0%, #ffe3ee 100%);
font-family: "Hiragino Kaku Gothic ProN", "Segoe UI", system-ui, sans-serif;
color: #6a2740;
}
.sg-eyebrow {
font-size: 11px;
font-weight: 700;
letter-spacing: 0.26em;
color: #d65e8c;
}
.sg-title {
margin-top: 4px;
font-size: 24px;
font-weight: 800;
letter-spacing: 0.04em;
color: #b23a6a;
}
.sg-cards {
margin-top: 18px;
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px;
}
/* ★主役:conic-gradient のボーダーを @property の角度で回転発光 */
.sg-card {
position: relative;
border-radius: 18px;
padding: 3px; /* この余白がグラデボーダーの太さ */
background:
conic-gradient(from var(--sg-angle),
#ff8fb3, #ffd1e0, #b39cff, #7fd6ff, #ff8fb3);
animation: sgRotate 5s linear infinite;
box-shadow: 0 10px 26px rgba(214,94,140,0.25);
transition: transform 0.25s ease;
}
.sg-card:hover { transform: translateY(-4px); }
@keyframes sgRotate {
to { --sg-angle: 360deg; }
}
/* 中身(白カード)。ボーダーだけ光らせる */
.sg-card::after {
content: "";
position: absolute;
inset: 3px;
border-radius: 15px;
background: #fff;
z-index: 0;
}
.sg-card > * { position: relative; z-index: 1; }
.sg-card__photo {
height: 96px;
border-radius: 15px 15px 0 0;
background: #ffd9e6 center/cover no-repeat;
position: relative;
}
/* メンバーごとに別写真(CSS変数では URL 連結できないため個別指定) */
.sg-card:nth-child(1) .sg-card__photo { background-image: url("https://picsum.photos/240/200?random=71"); }
.sg-card:nth-child(2) .sg-card__photo { background-image: url("https://picsum.photos/240/200?random=72"); }
.sg-card:nth-child(3) .sg-card__photo { background-image: url("https://picsum.photos/240/200?random=73"); }
.sg-card__photo::after {
content: "";
position: absolute;
inset: 0;
border-radius: 15px 15px 0 0;
background: linear-gradient(180deg, transparent, rgba(255,209,224,0.45));
mix-blend-mode: multiply;
}
.sg-card__color {
display: inline-block;
margin: 10px 12px 0;
font-size: 10px;
font-weight: 700;
padding: 3px 9px;
border-radius: 999px;
color: #fff;
background: var(--c, #ff8fb3);
}
.sg-card__name {
margin: 8px 12px 2px;
font-size: 15px;
font-weight: 800;
color: #b23a6a;
}
.sg-card__role {
margin: 0 12px 14px;
font-size: 10.5px;
color: #9a6076;
line-height: 1.5;
}
@media (prefers-reduced-motion: reduce) {
.sg-card { animation: none; }
}
JavaScript
// メンバーカードのホバーで回転速度を少し上げ、推し感を出す
(() => {
const cards = document.querySelectorAll(".sg-card");
if (!cards.length) return; // null安全
const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
if (reduce) return;
cards.forEach((card) => {
// ホバー中は発光ボーダーを速く回す
card.addEventListener("pointerenter", () => {
card.style.animationDuration = "2s";
});
card.addEventListener("pointerleave", () => {
card.style.animationDuration = "5s";
});
});
})();
コード
HTML
<!-- 回転グラデーションボーダー: conic-gradient を回し、カードの縁を発光させる -->
<div class="gb-stage">
<div class="gb-card">
<div class="gb-inner">
<span class="gb-badge">PRO</span>
<h1 class="gb-title">Glowing Border</h1>
<p class="gb-sub">@property で角度を回転させる conic-gradient ボーダー。価格表やバッジカードに。</p>
<button class="gb-cta" type="button">アップグレード</button>
</div>
</div>
</div>
CSS
/* @property で角度をアニメーション可能にし、conic-gradient ボーダーを回す */
* { box-sizing: border-box; margin: 0; padding: 0; }
/* カスタムプロパティを角度型として登録(回転アニメに必須) */
@property --gb-angle {
syntax: "<angle>";
initial-value: 0deg;
inherits: false;
}
.gb-stage {
min-height: 360px;
display: grid;
place-items: center;
padding: 24px;
font-family: "Segoe UI", "Hiragino Sans", system-ui, sans-serif;
background:
radial-gradient(120% 120% at 50% 0%, #1a1030 0%, #0a0716 70%);
}
/* カード外枠 = グラデボーダー本体 */
.gb-card {
position: relative;
border-radius: 22px;
padding: 2px; /* この余白が枠の太さ */
background: conic-gradient(
from var(--gb-angle),
#ff5f6d, #ffc371, #5ee7df, #7b88ff, #c479ff, #ff5f6d
);
animation: gb-spin 6s linear infinite;
box-shadow: 0 0 40px rgba(124, 136, 255, 0.35);
}
@keyframes gb-spin {
to { --gb-angle: 360deg; }
}
/* 内側パネル */
.gb-inner {
border-radius: 20px;
background: #120c24;
padding: 34px 40px;
text-align: center;
color: #f4f1ff;
max-width: 420px;
}
.gb-badge {
display: inline-block;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.2em;
padding: 5px 14px;
border-radius: 999px;
background: linear-gradient(90deg, #7b88ff, #c479ff);
color: #fff;
}
.gb-title {
margin: 14px 0 10px;
font-size: 32px;
font-weight: 800;
letter-spacing: 0.01em;
}
.gb-sub {
font-size: 13.5px;
line-height: 1.8;
color: rgba(244, 241, 255, 0.78);
}
.gb-cta {
margin-top: 22px;
font: inherit;
font-size: 13px;
font-weight: 700;
color: #120c24;
padding: 12px 28px;
border: none;
border-radius: 999px;
cursor: pointer;
background: linear-gradient(90deg, #5ee7df, #ffc371);
transition: transform 0.2s ease, filter 0.2s ease;
}
.gb-cta:hover {
transform: translateY(-2px);
filter: brightness(1.08);
}
/* 回転を止めても虹色の枠は残る */
@media (prefers-reduced-motion: reduce) {
.gb-card { animation: none; }
}
🤖 AIエージェント用プロンプト
このままコピーしてAIに貼り付け「追加する場所」だけ書き換えればOK
あなたは熟練のフロントエンドエンジニアです。私のWebサイトに「回転グラデーションボーダー」の効果を追加してください。
# 追加してほしい効果
回転グラデーションボーダー(背景 & グラデーション)
@property で角度を回転させた conic-gradient のボーダーがカードの縁を発光させる演出。価格表やバッジカードに使えます。
# 追加する場所
👉【ここに対象箇所を記入:例「トップのヒーローセクション」「お問い合わせボタン」「記事カードの一覧」など】
# 参考実装(この見た目・挙動を再現してください)
【HTML】
<!-- 回転グラデーションボーダー: conic-gradient を回し、カードの縁を発光させる -->
<div class="gb-stage">
<div class="gb-card">
<div class="gb-inner">
<span class="gb-badge">PRO</span>
<h1 class="gb-title">Glowing Border</h1>
<p class="gb-sub">@property で角度を回転させる conic-gradient ボーダー。価格表やバッジカードに。</p>
<button class="gb-cta" type="button">アップグレード</button>
</div>
</div>
</div>
【CSS】
/* @property で角度をアニメーション可能にし、conic-gradient ボーダーを回す */
* { box-sizing: border-box; margin: 0; padding: 0; }
/* カスタムプロパティを角度型として登録(回転アニメに必須) */
@property --gb-angle {
syntax: "<angle>";
initial-value: 0deg;
inherits: false;
}
.gb-stage {
min-height: 360px;
display: grid;
place-items: center;
padding: 24px;
font-family: "Segoe UI", "Hiragino Sans", system-ui, sans-serif;
background:
radial-gradient(120% 120% at 50% 0%, #1a1030 0%, #0a0716 70%);
}
/* カード外枠 = グラデボーダー本体 */
.gb-card {
position: relative;
border-radius: 22px;
padding: 2px; /* この余白が枠の太さ */
background: conic-gradient(
from var(--gb-angle),
#ff5f6d, #ffc371, #5ee7df, #7b88ff, #c479ff, #ff5f6d
);
animation: gb-spin 6s linear infinite;
box-shadow: 0 0 40px rgba(124, 136, 255, 0.35);
}
@keyframes gb-spin {
to { --gb-angle: 360deg; }
}
/* 内側パネル */
.gb-inner {
border-radius: 20px;
background: #120c24;
padding: 34px 40px;
text-align: center;
color: #f4f1ff;
max-width: 420px;
}
.gb-badge {
display: inline-block;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.2em;
padding: 5px 14px;
border-radius: 999px;
background: linear-gradient(90deg, #7b88ff, #c479ff);
color: #fff;
}
.gb-title {
margin: 14px 0 10px;
font-size: 32px;
font-weight: 800;
letter-spacing: 0.01em;
}
.gb-sub {
font-size: 13.5px;
line-height: 1.8;
color: rgba(244, 241, 255, 0.78);
}
.gb-cta {
margin-top: 22px;
font: inherit;
font-size: 13px;
font-weight: 700;
color: #120c24;
padding: 12px 28px;
border: none;
border-radius: 999px;
cursor: pointer;
background: linear-gradient(90deg, #5ee7df, #ffc371);
transition: transform 0.2s ease, filter 0.2s ease;
}
.gb-cta:hover {
transform: translateY(-2px);
filter: brightness(1.08);
}
/* 回転を止めても虹色の枠は残る */
@media (prefers-reduced-motion: reduce) {
.gb-card { animation: none; }
}
# 外部ライブラリ
なし(追加ライブラリ不要)
# 守ってほしいこと
- 既存のHTML構造・レイアウト・デザインを壊さないこと。必要に応じてクラス名・色・サイズを私のサイトに合わせて調整してよい。
- クラス名やidが既存と衝突しないよう、必要なら接頭辞で名前空間を分けること。
- レスポンシブ対応と prefers-reduced-motion への配慮を入れること。
- 私のサイトのフレームワーク(React / Vue / 素のHTML など)に合わせて実装すること。不明な場合は素のHTML/CSS/JSで提示し、組み込み手順も説明すること。
- 変更後の確認手順も簡潔に教えてください。