공부 모음집/실습 기록

[레이아웃] Layout 유형 (1)

leedaramji 2023. 10. 20. 14:58

Layout 유형 (1)



1) 구조 작업

 

HTML, CSS 구조화


 

2) 가운데 영역 작업

 

  • 각각의 영역 안에 .container를 만들어 준다.
  • container는 재활용 가능한 CSS 코드로 작성
  • 가운데 영역 너비 지정
  • margin: 0 auto; 👉🏻 가운데로 밀어준다.
  • height: inherit; 👉🏻 상속 받는다.

 

3) 미디어 쿼리

 

  • 변경할 코드를 작성해준다.
  • width 기본값 100%


 

기본) 1920px .container width 1200px

 

반응형) 1300px 이하 .container width 90%로 바뀜

 

반응형) 768px 이하 .container width 100%로 바뀜

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=, initial-scale=1.0">
    <title>Layout01-4 미디어쿼리</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .container {
            width: 1200px;
            height: inherit;
            background-color: rgba(0, 0, 0, 0.3);
            margin: 0 auto;
        }
        #header{
            height: 100px;
            background: lightgoldenrodyellow;
        }
        #slider{
            height: 300px;
            background-color: ghostwhite
        }
        #about{
            height: 580px;
            background-color: lightsalmon
        }   
        #footer{
            height: 100px;
            background-color: lightgoldenrodyellow;
        }
        /* 미디어쿼리 */
        @media (max-width: 1300px){
            .container {
                width: 90%;
            }
        }
        @media (max-width: 768px){
            .container {
                width: 100%;
            }    
        /* @media (max-width: 480px){
            .container {
                width: 100%;
            } */
        }
    </style>
</head>
<body>
    <div class="wrap">
        <header id="header">
            <div class="container"></div>
        </header>
        <section id="slider">
            <div class="container"></div>
        </section>
        <section id="about">
            <div class="container"></div>
        </section>
        <footer id="footer">
            <div class="container"></div>
        </footer>
    </div>
</body>
</html>