<!--

※ 반응형 웹 디자인

1.메타 코드 작성

<meta name="viewport" content="sidth=device-width, initial-scale=1">

2.미디어 쿼리(Media Query) 적용: 디바이스의 스크린 크기에 따라 다른 스타일 시트를 적용하는 것.

    2-1. 미디어 쿼리 적용방법

        a. <link> 로 적용

        <link rel="stylesheet" href="./css/fhd-1400.css" media="screen and (min-width:1400px) and (max-width:1920px)">

        <link rel="stylesheet" href="./css/hd-1000.css" media="screen and (min-width:1000px) and (max-width:1399px)">

        <link rel="stylesheet" href="./css/tb-768.css" media="screen and (min-width:760px) and (max-width:999px)">

        <link rel="stylesheet" href="./css/sm.css" media="screen and (max-width:759px)">

 

        b. @media 로 적용

        @media screen and (min-width:1400px) { }

        @media screen and (min-width:1000px) and (max-width:1399px) { }

        @media screen and (min-width:760px) and (max-width:999px) { }

        @media screen and (max-width:759px) { }

 

        ★ <link>보단 @media 를 주로 사용한다.

 

    2-2. 반응형 이미지

        이미지를 선택자로 선택한 후 width를 100%로 지정한다.  

 

    2-3. 부트스트랩(Bootstrap5)의 미디어 쿼리 중단점

        a.576px 미만(xs)

        b.576px 이상(sm)

        c.768px 이상(md)

        d.992px 이상(lg)

        e.1200px 이상(xl)

        f.1400px 이상(xxl)

-->

<!DOCTYPE html>

<html>

<head>

<meta name="viewport" content="sidth=device-width, initial-scale=1">

<meta charset="utf-8">

<title></title>

<link rel="stylesheet" href="./css/media.css">

</head>

 

<body>

    <h2>media query</h2>

    <div></div>

</body>

</html>

 

----------------media.css

@charset "utf-8";

/*media.css*/

 

@import url("reset.css");

 

h2 { padding-top:100pxfont-size:42pxcolor:#06ftext-align:centertext-transform:uppercase; }

div { width:95%height:500pxmargin:100px autobackground:#fc0; }

 

@media screen and (max-width:576px) { 

    body { background:#000; }

    h2 { font-size32pxcolor:#fff; }

    div { width:100%; }

}

/**/

 

@media screen and (min-width:576px) { 

    body { background:#a50; }

    h2 { font-size32pxcolor:#fff; }

    div { width:100%; }

}

/**/

 

@media screen and (min-width:768px) { 

    body{background:#999;}

}

/*tb:768px*/

 

@media screen and (min-width:1000px) { 

    body { background:#0a8; }

    h2 { color:#fff; }

    div { width:950px; }

}

/*hd:1024px*/

 

@media screen and (min-width:1400px) { 

    body { background:#06f; }

    h2 { color:#fff; }

    div { width:1350px; }

}

/*fhd:1920px*/

 

----------------reset.css

 

@charset "utf-8";

/*reset.css*/

 

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;700&display=swap');

@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@300;400;700&display=swap');

 

*margin:0padding:0box-sizing:border-box; }

body { font-family'Noto Sans KR'sans-seriffont-size:15pxcolor:#333background:#fff;}

h1h2h3h4h5h6 { font-family'Merriweather'serif; }

ul li { list-style:nonefloat:left; }

a { display:blocktext-decoration:none; }

img { width:100%; }

.clear { clear:both; }

 

 

-----------------------

 

<!DOCTYPE html>

<html>

<head>

<meta name="viewport" content="sidth=device-width, initial-scale=1">

<meta charset="utf-8">

<title></title>

<link rel="stylesheet" href="./css/header.css">

</head>

 

<body>

    <header>

        <div class="btn"></div>

        <h1>logo</h1>

 

        <nav>

            <ul>

                <li><a href="#">menu01</a></li>

                <li><a href="#">menu02</a></li>

                <li><a href="#">menu03</a></li>

                <li><a href="#">menu04</a></li>

            </ul>

        </nav>

    </header>

</body>

</html>

 

-----------------header.css

 

@charset "utf-8";

/*media.css*/

 

@import url("reset.css");

 

header {

    height70pxpadding0 50px;

    background#000;

}

h1 { position:absolutetop:15pxfont-size28pxcolor#ffftext-transformuppercase;}

a { padding0 20pxcolor#fff; }

a:hover { color#fc0; }

.btn { floatleftwidth40pxheight40pxmargin:15pxbackground#fffborder-radius5px; }

 

@media screen and (max-width:576px) { 

    header {displayblockpadding0; }

    h1 { left50%transformtranslateX(-50%); }

    nav {displaynone;}

}

/*sm:375px*/

 

@media screen and (min-width:576px) { 

    header {

        displayblock;

        padding0background#550;

    }

    h1 { left50%transformtranslateX(-50%); }

    nav {displaynone;}

}

/**/

 

@media screen and (min-width:768px) { 

    header

        background#086;}

    h1{left:80px;}

    a {padding0 15px;}

    nav {displayblockfloat:rightmargin-top25pxmargin-right50px;}

    .btn {displaynone;}

}

/*tb:768px*/

 

@media screen and (min-width:1000px) { 

    headerbackground#049;}

    a {padding0 30px;}

}

/*hd:1024px*/

 

@media screen and (min-width:1400px) { 

    header { background:#006;}

}

/*fhd:1920px*/

'Coding' 카테고리의 다른 글

CSS 선수학습(13)  (0) 2021.07.27
CSS 선수학습(11)  (0) 2021.07.26
CSS 선수학습(10)  (0) 2021.07.21
CSS 선수학습(9)  (0) 2021.07.21
CSS 복습/실습  (0) 2021.07.20

+ Recent posts