
학습자료 : https://youtu.be/o1HzOJfgugE?si=5fWNFz749byroCMg
isolation: isolate; 속성은 요소가 새로운 스태킹 컨텍스트를 생성하도록 해줌.<div class="parent">
<div class="child">Child 1 (z-index: 10)</div>
<div class="child" style="isolation: isolate;">Child 2 (z-index: 5)</div>
</div>
.parent {
position: relative;
z-index: 1;
background-color: #f0f0f0;
padding: 20px;
}
.child {
position: absolute;
width: 100px;
height: 100px;
background-color: #808080;
}
.child:nth-child(1) {
top: 0;
left: 0;
}
.child:nth-child(2) {
top: 50px;
left: 50px;
}
isolation: isolate;가 적용되어 새로운 스태킹 컨텍스트를 생성하므로, z-index가 5임에도 불구하고 부모 배경 위에 표시됩니다. 즉, Child 2의 z-index는 부모의 z-index와는 독립적으로 작용합니다.inset 속성은 top, right, bottom, left 속성을 한 번에 설정하는 속기(shorthand) 속성.box {
position: absolute;
inset: 10px 20px; /* top, bottom: 10px, left, right: 20px */
/* inset: 10px 20px 30px 40px; top: 10px, right: 20px, bottom: 30px, left: 40px */
background-color: #808080;
width: 100px;
height: 100px;
}
.box2 {
position: absolute;
inset: auto 20px 30px; /* top: auto, right: 20px, bottom: 30px, left: auto */
background-color: #808080;
width: 100px;
height: 100px;
}
counter-reset 속성으로 카운터를 초기화하고, counter-increment 속성으로 값을 증가시키며, content 속성과 counter() 함수를 사용하여 카운터의 값을 표시<h1>Sections</h1>
<section>
<h2>Section 1</h2>
<p>Content for section 1.</p>
</section>
<section>
<h2>Section 2</h2>
<p>Content for section 2.</p>
</section>
<section>
<h2>Section 3</h2>
<p>Content for section 3.</p>
</section>
```css
body {
counter-reset: section; /* body 요소에 'section' 카운터 초기화 */
}
section {
counter-increment: section; /* 각 section 요소마다 'section' 카운터 증가 */
}
h2::before {
content: "Section " counter(section) ": "; /* h2 요소 앞에 카운터 값 표시 */
}
section의 h2 제목 앞에 "Section 1: ", "Section 2: ", "Section 3: "과 같이 섹션 번호가 자동으로 매겨집니다.<img src="image.jpg" alt="Original Image" class="original">
<img src="image.jpg" alt="Grayscale Image" class="grayscale">
<div class="shadow-box">Text with shadow</div>
<div class="drop-shadow-box">Text with drop shadow</div>
```css
.original {
/* Original image */
}
.grayscale {
filter: grayscale(100%); /* 이미지를 흑백으로 변환 */
}
.shadow-box {
background-color: #808080;
box-shadow: 5px 5px 5px #606060; /* 일반적인 박스 그림자 */
padding: 10px;
}
.drop-shadow-box {
background-color: #808080;
filter: drop-shadow(5px 5px 5px #606060); /* 요소의 윤곽에 따라 그림자 생성 */
padding: 10px;
}
contain 속성은 브라우저가 요소의 렌더링을 최적화할 수 있도록 해당 요소의 범위를 제한하는 데 사용.<div class="container">
<div class="item" style="contain: content;">
<p>This content is contained.</p>
<p>Changes here won't affect the rest of the page.</p>
</div>
<div class="item">
<p>This content is not contained.</p>
</div>
</div>
```css
.container {
/* Styles for the container */
}
.item {
/* 공통 스타일 */
}
contain: content;가 적용된 .item 내부의 변경 사항(예: 크기, 스타일 변경)은 페이지의 다른 요소에 영향을 미치지 않음. 이는 브라우저가 렌더링을 최적화하고 성능을 향상시키는 데 도움이 됨.