본문 바로가기

css

12장 예제- 템플릿 영역을 만들어 배치하기

<!DOCTYPE html>
<html lang="ko">
<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>템플릿 영역을 만들어 배치하기 </title>
  <style>
   #wrapper {
    width:700px;
    display:grid;
    grid-template-columns:repeat(3,1fr);
    grid-template-rows:repeat(3,100px);
    grid-template-areas:
    "box1 box1 box1"
    "box2 box3 box3"
    "box2 . box4";
   }

   .box {
    padding:15px;
    color:#fff;
    font-weight:bold;
    text-align:center;
   }

   .box1{
    background-color:#3689ff;
    grid-area:box1;
   }

   .box2{
    background-color:#00cf12;
    grid-area:box2;
   }

   .box3{
    background-color:#ff9019;
    grid-area:box3;
   }

   .box4{
    background-color:#ffd000;
    grid-area:box4;
   }
  </style>
</head>
<body>
  <div id="wrapper">
    <div class="box box1">box1</div>
    <div class="box box2">box2</div>
    <div class="box box3">box3</div>
    <div class="box box4">box4</div>
  </div>
</body>
</html>