<body>부분소스
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <body> <div id="header"> <h1>GOOGLE</h1> </div> <div id="menu"> <ul> <li id="mn1"><a href="#">menu1</a></li> <li id="mn2"><a href="#">menu2</a></li> <li id="mn3"><a href="#">menu3</a></li> <li id="mn4"><a href="#">menu4</a></li> </ul> </div> <div id="content"> <div></div> <h1>환영합니다</h1> <p>한빛 교육센터에 오신것을 환영합니다</p> <p>이곳에는 내용이 쏼라쏼라</p><br/> </div> <div id="footer"> 정책 및 약관|회사소개|광고|마이비즈니스|제휴제안|이용약관|개인정보취급방침|청소년보호정책|고객센터 </div> </body> | cs |
<head>부분소스
1. PC 환경
소스
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | @media screen and (min-width:1024px){ /*pc 환경*/ #header{ width: 100%; height: 80px; background-image: url(googlelogo.png); background-repeat: no-repeat; background-size:180px 70px; } #header>h1{ position: absolute; left: -999px; } #menu{ background-color: lightskyblue; overflow: hidden; } #menu>ul{ width: 400px; margin: 0px auto; } #menu>ul>li{ float: left; list-style: none; } #menu>ul>li>a{ text-decoration: none; border-left: solid white 5px; border-right: solid white 5px; display: inline-block; width: 100px; height: 30px; box-sizing: border-box; text-align: center; color: floralwhite; font-weight: bold; } #menu>ul>li>a:hover{ color: royalblue; } #content{ clear: both; } #content>div{ width: 100%; height: 500px; background-image: url(jung2.png); background-repeat: no-repeat; background-size: 100%; } } | cs |
결과
2. 태블릿 환경
소스
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | @media screen and (min-width:400px) and (max-width:1023px){ /*태블릿 환경*/ #header{ width: 100%; height: 80px; background-image: url(googlelogo.png); background-repeat: no-repeat; background-size: 180px 70px; } #header>h1{ position: absolute; left: -999px; } #menu>ul>li{ background-color: darksalmon; display: inline-block; width: 50%; height: 50px; border-bottom: solid white 3px; } #menu>ul>li>a{ display: inline-block; width: 100%; height: 100%; text-align: center; text-decoration: none; font-size: 1.5em; color: white; line-height: 50px; font-weight: bold; /*text-transform: uppercase;*/ font-variant: small-caps; } } | cs |
결과
3. 모바일 환경
소스
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | @media screen and (max-width:399px){ /*모바일 환경*/ #header>h1{ text-align: center; } #menu>ul{ /*display: none;*/ } #menu>ul>li{ background-color: darksalmon; border-left: solid red 10px; border-bottom: solid white 3px; } #menu>ul>li>a{ text-decoration: none; color: white; } } | cs |
결과
기준 px를 잡아 모바일 혹은 태블릿의 크기를 @media screen and (max-width:399px) 혹은 @media screen and (min-width:400px)
등으로 잡아 작성한 것이다.
웹창을 늘렸다 줄였다하는 대로 반응하는 반응형 웹이다.
전체소스
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>반응형 웹</title> <style> *{ margin: 0px; padding: 0px; } @media screen and (max-width:399px){ /*모바일 환경*/ #header>h1{ text-align: center; } #menu>ul{ /*display: none;*/ } #menu>ul>li{ background-color: darksalmon; border-left: solid red 10px; border-bottom: solid white 3px; } #menu>ul>li>a{ text-decoration: none; color: white; } } @media screen and (min-width:400px) and (max-width:1023px){ /*태블릿 환경*/ #header{ width: 100%; height: 80px; background-image: url(googlelogo.png); background-repeat: no-repeat; background-size: 180px 70px; } #header>h1{ position: absolute; left: -999px; } #menu>ul>li{ background-color: darksalmon; display: inline-block; width: 50%; height: 50px; border-bottom: solid white 3px; } #menu>ul>li>a{ display: inline-block; width: 100%; height: 100%; text-align: center; text-decoration: none; font-size: 1.5em; color: white; line-height: 50px; font-weight: bold; /*text-transform: uppercase;*/ font-variant: small-caps; } } @media screen and (min-width:1024px){ /*pc 환경*/ #header{ width: 100%; height: 80px; background-image: url(googlelogo.png); background-repeat: no-repeat; background-size:180px 70px; } #header>h1{ position: absolute; left: -999px; } #menu{ background-color: lightskyblue; overflow: hidden; } #menu>ul{ width: 400px; margin: 0px auto; } #menu>ul>li{ float: left; list-style: none; } #menu>ul>li>a{ text-decoration: none; border-left: solid white 5px; border-right: solid white 5px; display: inline-block; width: 100px; height: 30px; box-sizing: border-box; text-align: center; color: floralwhite; font-weight: bold; } #menu>ul>li>a:hover{ color: royalblue; } #content{ clear: both; } #content>div{ width: 100%; height: 500px; background-image: url(jung2.png); background-repeat: no-repeat; background-size: 100%; } } </style> </head> <body> <div id="header"> <h1>GOOGLE</h1> </div> <div id="menu"> <ul> <li id="mn1"><a href="#">menu1</a></li> <li id="mn2"><a href="#">menu2</a></li> <li id="mn3"><a href="#">menu3</a></li> <li id="mn4"><a href="#">menu4</a></li> </ul> </div> <div id="content"> <div></div> <h1>환영합니다</h1> <p>한빛 교육센터에 오신것을 환영합니다</p> <p>이곳에는 내용이 쏼라쏼라</p><br/> </div> <div id="footer"> 정책 및 약관|회사소개|광고|마이비즈니스|제휴제안|이용약관|개인정보취급방침|청소년보호정책|고객센터 </div> </body> </html> | cs |
'* Programming > HTML&CSS' 카테고리의 다른 글
[HTML/CSS] 그리드(grid)를 이용한 반응형 웹 (0) | 2016.09.27 |
---|---|
[HTML/CSS] 그리드(grid) (0) | 2016.09.27 |
[HTML/CSS] 위치 변경하기 (1) | 2016.09.26 |
[HTML/CSS] 제휴 사이트 연결하기 (0) | 2016.09.26 |
[HTML/CSS] 숨김기능&선택지시자 (+와 ~의 차이) (0) | 2016.09.26 |