<!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>position 속성</title>
<style>
div {
width: 200px;
height: 200px;
font-size: 30px;
color: #fff;
background: seagreen;
border: 10px solid #000;
}
/* #box1 {
z-index: 3;
position: absolute;
left: 50px;
top: 50px;
}
#box2 {
z-index: 2;
position: absolute;
left: 150px;
top: 150px;
}
#box3 {
z-index: 1;
position: absolute;
left: 250px;
top: 250px;
} */
/* #box1 {
z-index: 3;
position: relative;
left: 50px;
top: 50px;
}
#box2 {
z-index: 2;
position: relative;
left: 150px;
top: 150px;
}
#box3 {
z-index: 1;
position: relative;
left: 250px;
top: 250px;
} */
#box {
width: 800px;
height: 700px;
background: #ddd;
/* box1,2,3의 상위 요소인 box에 relative */
position: relative;
}
#box1 {
z-index: 3;
position: absolute;
right: 50px;
top: 50px;
}
#box2 {
z-index: 2;
position: absolute;
left: 150px;
bottom: 150px;
}
#box3 {
z-index: 1;
position: absolute;
left: 50%;
top: 250px;
}
</style>
</head>
<body>
<div id="box">
<div id="box1">box1</div>
<div id="box2">box2</div>
<div id="box3">box3</div>
</div>
</body>
</html>