질문:
순수 CSS에서 가능합니까? 여러 개의 끈적한 요소를 서로 쌓으시겠습니까?
예:
https://webthemez.com/demo/sticky-multi-header-scroll/index.html
사용을 선호합니다 JavaScript 구현이 아닌 순수 CSS입니다. 여러 개의 끈적끈적한 요소를 시도해 보았지만 다른 끈적한 요소를 압착하는 것을 막을 수는 없습니다. 동일한 스태킹 컨텍스트(
#sticky .sticky-1, #sticky .sticky-2 { position: sticky; } #sticky .sticky-1 { top: 1em; z-index: 1; } #sticky .sticky-2 { top: 2em; z-index: 1; }
)에 넣으려고 했지만 아래 .html 스니펫에서 볼 수 있듯이 작동하지 않았습니다. 어떤 통찰력이라도 대단히 감사하겠습니다!
<code class="html"><div id="container"> <article id="sticky"> <header> </header> <main> <h1 class="sticky-1">Sticky heading</h1 > <p>here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. Some copy goes here. </p> </main> <section> <h2 class="sticky-2">Both headings should stick at the same time.</h2 ></code>
위 내용은 순수 CSS에서 여러 개의 고정 요소를 서로 쌓을 수 있나요?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!