웹프로그래밍 CSS3/CSS3 레이아웃

position:absolute 사용하기

별초롱언니 2025. 3. 24. 09:22
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="../../CSS/ch08/absolute.css">
  <title>Document</title>
</head>
<body>
  <div class="level1">
    <div class="level2">
      <div class="level3">
        <p class="content">내용</p>
      </div>
    </div>
  </div>
</body>
</html>
@import url(../reset.css);

.level1 {
  width: 300px;
  height: 300px;
  background-color: yellow;
  display: flex;
  justify-content: center;
  align-items: center;
}

.level2 {
  background-color: aqua;
  width: 200px;
  height: 200px;
  align-items: center;
  display: flex;
  justify-content: center;
}

.level3 {
  position: relative;
  width: 100px;
  height: 100px;
  background-color: pink;
}

.content {
  position: absolute;
  top: 0%;
  left: 0px; 
}