ホームページ > ウェブフロントエンド > CSSチュートリアル > オープンディテール要素に背景を置きます

オープンディテール要素に背景を置きます

Jennifer Aniston
リリース: 2025-03-23 09:39:10
オリジナル
264 人が閲覧しました

Put a Background on Open Details Elements

One thing that can be just a smidge funky about the

element is that, when open, it’s not always 100% clear what is inside that element and what isn’t. I’m not saying that always matters or that it’s a particularly hard problem to solve, I’m just noting it as it came up recently for me.

Here’s a visual example:

The solution is… CSS. Style the

somewhat uniquely, and that problem goes away. Even if you want the typography to be the same, or you don’t want any exclusive styling until the
is opened, it’s still possible. Using an alpha-transparent fill, you can even make sure that deeper-nested
remain clear.

Here’s that CSS:

details[open] {
  --bg: rgb(0 0 0 / 0.2);
  background: var(--bg);
  outline: 1rem solid var(--bg);
  margin: 0 0 2rem 0;
}
ログイン後にコピー

And the demo:

以上がオープンディテール要素に背景を置きますの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のチュートリアル
詳細>
関連するチュートリアル
人気のおすすめ
最新のコース
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート