다른 어떤 것보다 무조건 위에 출력해야한다
그러면 z 인덱스를 그냥 9999 이런 식으로 큰 숫자를 준다
그럴 때 주로 쓰임
광고 같은 것들, 위에 뜨게 하고 싶을 때
- 연습코드
더보기
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.container {
position: relative;
}
.box {
position: absolute;
width: 100px;
height: 100px;
}
.red {
background-color: red;
top: 50px;
left: 50px;
/* z-index: 3; */
}
.green {
background-color: green;
top: 100px;
left: 100px;
/* z-index: 2; */
}
.blue {
background-color: blue;
top: 150px;
left: 150px;
/* z-index: 1; */
}
</style>
</head>
<body>
<div class="container">
<div class="box red"></div>
<div class="box green"></div>
<div class="box blue"></div>
</div>
</body>
</html>
'WEB > CSS_ concepts' 카테고리의 다른 글
[CSS Flexbox] Flex Container 지정 (0) | 2024.03.07 |
---|---|
CSS Flexbox (0) | 2024.03.07 |
sticky position (0) | 2024.03.07 |
Fixed Position (0) | 2024.03.07 |
Absolute position (0) | 2024.03.07 |