1. static

image.png

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <style>
      .box1 {
        width: 300px;
        height: 300px;
        background-color: yellow;
        display: inline-block;
      }
      .box2 {
        width: 300px;
        height: 300px;
        background-color: red;
        display: inline-block;
      }
      .box3 {
        width: 300px;
        height: 300px;
        background-color: green;
        display: inline-block;
      }
      .box4 {
        width: 300px;
        height: 300px;
        background-color: blue;
        display: inline-block;
      }
      .box5 {
        width: 300px;
        height: 300px;
        background-color: bisque;
        display: inline-block;
      }
    </style>
  </head>
  <body>
    <h1>position static, relative, absoulte, fixed</h1>
    <hr />
    <div class="box1"></div>
    <div class="box2"></div>
    <div class="box3"></div>
    <div class="box4"></div>
    <div class="box5"></div>
  </body>
</html>

2. relative

<aside> 💡

위치 이동이 가능하다.

기준은 원래 static 위치에서 이동함!!

</aside>

image.png

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <style>
      .box1 {
        width: 300px;
        height: 300px;
        background-color: yellow;
        display: inline-block;
      }
      .box2 {
        width: 300px;
        height: 300px;
        background-color: red;
        display: inline-block;
      }
      .box3 {
        width: 300px;
        height: 300px;
        background-color: green;
        display: inline-block;
      }
      .box4 {
        width: 300px;
        height: 300px;
        background-color: blue;
        display: inline-block;
      }
      .box5 {
        width: 300px;
        height: 300px;
        background-color: bisque;
        display: inline-block;
      }
    </style>
  </head>
  <body>
    <h1>position static, relative, absoulte, fixed</h1>
    <hr />
    <div class="box1"></div>
    <div class="box2"></div>
    <div class="box3"></div>
    <div class="box4"></div>
    <div class="box5"></div>
  </body>
</html>

3. absoulte

<aside> 💡

absoulte는 도화지를 하나 더 만들어서 위로 올리는 거다.

새로운 도화지에 있기 때문에 left, top 등이 브라우저 전체 화면에서 움직인다.

</aside>

image.png

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <style>
      .box1 {
        width: 300px;
        height: 300px;
        background-color: yellow;
        display: inline-block;
      }
      .box2 {
        width: 300px;
        height: 300px;
        background-color: red;
        display: inline-block;
        position: absolute;
        bottom: 20px;
        left: 300px;
      }
      .box3 {
        width: 300px;
        height: 300px;
        background-color: green;
        display: inline-block;
      }
      .box4 {
        width: 300px;
        height: 300px;
        background-color: blue;
        display: inline-block;
      }
      .box5 {
        width: 300px;
        height: 300px;
        background-color: bisque;
        display: inline-block;
      }
    </style>
  </head>
  <body>
    <h1>position static, relative, absoulte, fixed</h1>
    <hr />
    <div class="box1"></div>
    <div class="box2"></div>
    <div class="box3"></div>
    <div class="box4"></div>
    <div class="box5"></div>
  </body>
</html>

4. 따라다니는 디자인 만들기 (1)

image.png

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .my_input {
        height: 100px;
      }
      .box {
        border: 1px solid black;
        padding: 5px;
        position: relative;
      }
      .new_paper {
        position: absolute;
        left: 20px;
        top: 20px;
      }

      .color_box {
        width: 100px;
        height: 100px;
        background-color: aqua;
        border: 1px solid black;
      }
    </style>
  </head>
  <body>
    <div class="color_box">1</div>
    <div class="box">
      <div class="new_paper">🛻</div>
      <input class="my_input" type="text" />
    </div>
  </body>
</html>

5. 따라다니는 디자인 만들기 (2)

image.png