그럼에도 불구하고

👨‍💻

[Responsive web] 반응형 페이지 layout 만들기 Ver_1 본문

HTML, CSS/Responsive web

[Responsive web] 반응형 페이지 layout 만들기 Ver_1

zenghyun 2023. 1. 18. 15:16

layout 만들기 Ver_1

 

 

 

시맨틱 태그 참고 : https://despiteallthat.tistory.com/57

 

[HTML] 시맨틱 웹(Sementic Web) / 시맨틱 태그(Sementic tag)

오늘은 시맨틱 웹(Sementic Web)과 시맨틱 태그(Sementic tag)에 대해 알아보자 [ 시멘틱 웹 ] 시멘틱 웹이란? 시멘틱 웹은 '의미론적인 웹'이라는 뜻으로, 현재의 인터넷과 같은 분산 환경에서 리소스(웹

despiteallthat.tistory.com

 

 

<!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>Layout</title>
  <style>
    * {
      padding: 0;
      margin: 0;
    }

    body {
      background-color: #f3e5f5;
    }

    #wrap {
      width: 1200px;
      margin: 0 auto;
    }

    header {
      width: 100%;
      height: 150px;
      background-color: #9575cd;
    }

    aside {
      width: 30%;
      height: 700px;
      background-color: #7e57c2;
      float: left;
    }

    section {
      width: 70%;
      height: 700px;
      background-color: #673ab7;
      float: left;
    }

    footer {
      width: 100%;
      height: 150px;
      background-color: #5e35b1;
      clear: both;
    }

    /* 반응형 페이지 할 때는 width 스크롤바가 나오면 안됨 */
    /* max-width 값은 전체 너비보다 좀 크게 */

    /* 화면 너비 0 ~ 1200px */
    @media (max-width:1200px) {
      #wrap {
        width: 98%;
      }
    }

    /* 화면너비 0 ~ 768px */
    @media (max-width:768px) {
      #wrap {
        width: 95%;
      }
    }

    /* 화면너비 0 ~ 576px */
    @media (max-width:596px) {
      #wrap {
        width: 100%;
      }

      header {
        height: 250px;
      }

      footer {
        height: 200px;
      }
    }

    /* 화면 너비 0 ~ 480px */
    @media (max-width:500px) {
      #wrap {
        width: 100%;
      }

      header {
        height: 300px;
      }

      aside {
        float: none;
        width: 100%;
        height: 200px;
      }

      section {
        float: none;
        width: 100%;
        height: 400px;
      }
    }
  </style>
</head>

<body>
  <div id="wrap">
    <header></header>
    <aside></aside>
    <section></section>
    <footer></footer>
  </div>
</body>

</html>

 

 

※ 화면너비 1200px 초과

#wrap의 영역의 width 1200px

 

※ 화면 너비 0 ~ 1200px 

 

@media (max-width:1200px){
      #wrap { width: 98%; }
    }

#wrap 영역의 width 전체 화면의 98% 

 

 

※ 화면 너비 0 ~ 768px

 

 /* 화면너비 0 ~ 768px */
    @media (max-width:768px){
      #wrap { width: 95%;}
    }

#wrap 영역의 width 전체 화면의 95% 

 

 

※ 화면 너비 0 ~ 576px

width를 100%로 지정할 때, max-width 값은 내가 나타낼 px보다 조금 크게 지정하는 것이 좋다.

 

=> 전체 너비와 같게 하면 상황에 따라 화면이 잘리는 경우가 생기기 때문!!

예를 들어 576px로 지정하고 싶으면 max-width를 596px로 20px 정도의 여분을 준다.  

 

/* 화면너비 0 ~ 576px */
    @media (max-width:596px){
      #wrap { width: 100%;}
      header { height: 250px;}
      footer { height: 200px;}
    }

 

 

※ 화면 너비 0 ~ 480px

 /* 화면 너비 0 ~ 480px */
    @media (max-width:500px){
      #wrap { width: 100%;}
      header { height: 300px;}
      aside { float: none; width: 100%; height: 200px;}
      section { float: none; width: 100%; height: 400px;}
    }

Comments