Control Parent from Child with :has()
CODE PREVIEW
エディタを読み込み中…
P
Prompt
Create a demo showing how CSS :has() selector can style parent elements based on child states. Include interactive examples like checkbox toggle, hover effect, and active state.
CSSの:has()擬似クラスを使うと、子要素の状態に応じて親要素をスタイリングできます。このデモでは3つのインタラクティブな例を紹介:チェックボックスで親の枠線と背景が変化、スパンにホバーで親が拡大、ボタンを押し続けるとコンテナの色が変わります。JavaScript不要、純粋なCSS条件付きスタイリングです。
Prompt Overview
The CSS :has() pseudo-class allows styling a parent element based on the state of its children. This demo shows three interactive examples: a checkbox toggles the parent's border and background, hovering over a span transforms the parent, and pressing a button changes the container's color. No JavaScript required — pure CSS conditional styling.
Was this prompt helpful?
Comments
Comments appear after moderation
この記事が役に立ったら投げ銭で応援
Apple Pay / Google Pay / カード (Visa/Mastercard/JCB/Amex) / Link / Alipay / WeChat Pay 対応 · Stripeで安全に決済
開発者が選ぶ最強ツール集
運営者が毎日使っているツール・ガジェット 6選