> 웹 프론트엔드 > CSS 튜토리얼 > 열린 세부 사항 요소에 대한 배경 지정

열린 세부 사항 요소에 대한 배경 지정

Jennifer Aniston
풀어 주다: 2025-03-23 09:39:10
원래의
259명이 탐색했습니다.

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 중국어 웹사이트의 기타 관련 기사를 참조하세요!

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿