HTML・CSS・JavaScript エディター
HTML、CSS、JavaScript を編集し、画面幅を変えながらプレビューとコンソール出力を確認できます。
HTML・CSS・JavaScript エディター
<main class="studio">
<div class="visual" aria-hidden="true">
<div class="orb"></div>
<div class="orbit"></div>
</div>
<section>
<p class="eyebrow">INTERACTIVE DEMO</p>
<h1>Color Studio</h1>
<p class="description">Pick a palette and inspect the event in the console.</p>
<div class="swatches" aria-label="Palettes">
<button type="button" data-theme="mint" aria-pressed="true">Mint</button>
<button type="button" data-theme="iris" aria-pressed="false">Iris</button>
<button type="button" data-theme="amber" aria-pressed="false">Amber</button>
</div>
</section>
</main>:root {
--panel: #e6f6eb;
--ink: #174333;
--accent: #6bd3a8;
--deep: #23765b;
font-family: system-ui, sans-serif;
}
:root[data-theme="iris"] {
--panel: #f2edfb;
--ink: #3f2a67;
--accent: #be9dff;
--deep: #7856b1;
}
:root[data-theme="amber"] {
--panel: #fff0d9;
--ink: #5f3719;
--accent: #fec879;
--deep: #ba6c32;
}
* { box-sizing: border-box; }
body { margin: 0; padding: clamp(16px, 6vw, 40px); background: #fbfcf9; color: var(--ink); }
.studio { max-width: 530px; margin: auto; overflow: hidden; border: 1px solid #1a473423; border-radius: 19px; background: white; }
.visual { position: relative; display: grid; height: clamp(94px, 27vw, 145px); isolation: isolate; place-items: center; overflow: hidden; background: var(--panel); }
.orb {
width: min(110px, 33vw); aspect-ratio: 1; border-radius: 50%;
background: radial-gradient(circle at 30% 27%, #fff7, transparent 41%), linear-gradient(145deg, var(--accent), var(--deep));
box-shadow: 14px 16px 34px #172d363d;
}
.orbit { position: absolute; width: min(185px, 62vw); height: 43%; border: 1px solid var(--deep); border-radius: 50%; transform: rotate(-19deg); opacity: .55; }
section { padding: 13px 21px 18px; }
.eyebrow { margin: 0 0 3px; font-size: 9px; font-weight: 750; letter-spacing: .16em; }
h1 { margin: 0; font-size: clamp(1.45rem, 5vw, 2.2rem); letter-spacing: -.055em; line-height: 1.07; }
.description { margin: 6px 0 12px; font-size: .82rem; max-width: 38ch; }
.swatches { display: flex; flex-wrap: wrap; gap: 5px; }
button { border: 1px solid #192b302b; border-radius: 6px; padding: 5px 10px; color: var(--ink); background: white; font: inherit; font-size: .76rem; cursor: pointer; }
button[aria-pressed="true"] { border-color: var(--deep); background: var(--panel); font-weight: 700; }const swatches = document.querySelectorAll("[data-theme]");
for (const button of swatches) {
button.addEventListener("click", () => {
document.documentElement.dataset.theme = button.dataset.theme;
for (const option of swatches) {
option.setAttribute("aria-pressed", String(option === button));
}
console.log("Palette changed", { palette: button.dataset.theme });
});
}
console.info("Color Studio is ready");16 行
ウェブプレビュー
ページを予測するために実行を選択します。
コンソール
0 入り口実行 JavaScript ログやエラーはこちらからご覧ください。
HTML・CSS・JavaScript を組み合わせて試す
マークアップとスタイルを変更したら JavaScript のイベント処理を追加し、プレビュー画面で動作を試します。
コメント
会議に参加するためにアカウントを登録または作成します。
コメントを積み重ねる...