Development/HTML · CSS
[HTML/CSS] z-index
레오나르도 다빈츠
2021. 8. 7. 17:26
- z-index이 같은 값일 경우 HTML상 아래인 것이 먼저 적용된다.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.contents {
width: 500px;
height: 500px;
position: relative;
background-color: pink;
}
.contents div {
width: 100px;
height: 100px;
}
.box1 {
background-color: red;
position: absolute;
top: 50px;
left: 80px;
z-index: 3;
}
.box2 {
background-color: orange;
position: absolute;
top: 70px;
left: 100px;
z-index: 3;
}
.box3 {
background-color: blue;
position: absolute;
top: 90px;
left: 120px;
z-index: 2;
}
</style>
</head>
<body>
<div class="contents">
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
</div>
</body></html>
개인적으로 공부한 내용을 정리하는 블로그로
잘못된 개념을 게시하지않도록 주의하고 있으나 오류가 있을 수 있습니다.