[2021.07.28] 인턴 +149 HTML Layout - 16 (레이아웃)
HTML 레이아웃 요소
* <header>
-> 문서 또는 섹션의 헤더를 정의
* <nav>
-> 탐색 링크 세트를 정의
* <section>
-> 문서의 섹션을 정의
* <article>
-> 독립적이고 독립적인 콘텐츠를 정의
* <aside>
-> 콘텐츠 이외의 콘텐츠 정의(사이드바 등)
* <footer>
-> 문서 또는 섹션의 바닥글을 정의
* <details>
-> 사용자가 필요에 따라 열고 닫을 수 있는 추가 세부 정보 정의
* <summary> - <details>
-> 요소 의 제목을 정의
----------------------------------------------------------------------------------------------------------------------------------
HTML 레이아웃 기법(HTML Layout Techniques)
1.CSS 프레임워크(CSS framework)
- 레이아웃을 빠르게 만들고 싶다면 W3.CSS 또는 Bootstrap 과 같은 CSS 프레임워크를 사용
2.CSS 부동 속성(CSS float property)
- CSS float속성을 사용하여 전체 웹 레이아웃을 수행하는 것이 일반적
- 단점: 부동 요소는 문서 흐름에 연결되어 유연성이 좋지 않음
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS Template</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box;
}
body {
font-family: Arial, Helvetica, sans-serif;
}
/* Style the header */
header {
background-color: #666;
padding: 30px;
text-align: center;
font-size: 35px;
color: white;
}
/* Create two columns/boxes that floats next to each other */
nav {
float: left;
width: 30%;
height: 300px; /* only for demonstration, should be removed */
background: #ccc;
padding: 20px;
}
/* Style the list inside the menu */
nav ul {
list-style-type: none;
padding: 0;
}
article {
float: left;
padding: 20px;
width: 70%;
background-color: #f1f1f1;
height: 300px; /* only for demonstration, should be removed */
}
/* Clear floats after the columns */
section::after {
content: "";
display: table;
clear: both;
}
/* Style the footer */
footer {
background-color: #777;
padding: 10px;
text-align: center;
color: white;
}
/* Responsive layout - makes the two columns/boxes stack on top of each other instead of next to each other, on small screens */
@media (max-width: 600px) {
nav, article {
width: 100%;
height: auto;
}
}
</style>
</head>
<body>
<h2>CSS Layout Float</h2>
<p>In this example, we have created a header, two columns/boxes and a footer. On smaller screens, the columns will stack on top of each other.</p>
<p>Resize the browser window to see the responsive effect (you will learn more about this in our next chapter - HTML Responsive.)</p>
<header>
<h2>Cities</h2>
</header>
<section>
<nav>
<ul>
<li><a href="#">London</a></li>
<li><a href="#">Paris</a></li>
<li><a href="#">Tokyo</a></li>
</ul>
</nav>
<article>
<h1>London</h1>
<p>London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.</p>
<p>Standing on the River Thames, London has been a major settlement for two millennia, its history going back to its founding by the Romans, who named it Londinium.</p>
</article>
</section>
<footer>
<p>Footer</p>
</footer>
</body>
</html>
<출력 결과>
3. CSS 플렉스박스(CSS flexbox)
- 페이지 레이아웃이 다양한 화면 크기와 다양한 디스플레이 장치를 수용해야 할 때, 요소가 예측 가능하게 작동함
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS Template</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box;
}
body {
font-family: Arial, Helvetica, sans-serif;
}
/* Style the header */
header {
background-color: #666;
padding: 30px;
text-align: center;
font-size: 35px;
color: white;
}
/* Container for flexboxes */
section {
display: -webkit-flex;
display: flex;
}
/* Style the navigation menu */
nav {
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
background: #ccc;
padding: 20px;
}
/* Style the list inside the menu */
nav ul {
list-style-type: none;
padding: 0;
}
/* Style the content */
article {
-webkit-flex: 3;
-ms-flex: 3;
flex: 3;
background-color: #f1f1f1;
padding: 10px;
}
/* Style the footer */
footer {
background-color: #777;
padding: 10px;
text-align: center;
color: white;
}
/* Responsive layout - makes the menu and the content (inside the section) sit on top of each other instead of next to each other */
@media (max-width: 600px) {
section {
-webkit-flex-direction: column;
flex-direction: column;
}
}
</style>
</head>
<body>
<h2>CSS Layout Flexbox</h2>
<p>In this example, we have created a header, two columns/boxes and a footer. On smaller screens, the columns will stack on top of each other.</p>
<p>Resize the browser window to see the responsive effect.</p>
<p><strong>Note:</strong> Flexbox is not supported in Internet Explorer 10 and earlier versions.</p>
<header>
<h2>Cities</h2>
</header>
<section>
<nav>
<ul>
<li><a href="#">London</a></li>
<li><a href="#">Paris</a></li>
<li><a href="#">Tokyo</a></li>
</ul>
</nav>
<article>
<h1>London</h1>
<p>London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.</p>
<p>Standing on the River Thames, London has been a major settlement for two millennia, its history going back to its founding by the Romans, who named it Londinium.</p>
</article>
</section>
<footer>
<p>Footer</p>
</footer>
</body>
</html>
<출력 결과>
4. CSS 그리드(CSS grid)
- 행과 열이 있는 그리드 기반 레이아웃 시스템을 제공
'Web' 카테고리의 다른 글
[2021.07.28] 인턴 +149 도메인 서버에 사용할 HTML 레이아웃을 만들어 보자 (0) | 2021.07.28 |
---|---|
[2021.07.28] 인턴 +149 HTML Head Element - 15 (HTML 헤드 요소) (0) | 2021.07.28 |
[2021.07.28] 인턴 +149 HTML JavaScript - 14 (HTML 자바스크립트) (0) | 2021.07.28 |
[2021.07.28] 인턴 +149 HTML id & iframes - 13 (0) | 2021.07.28 |
[2021.07.28] 인턴 +149 HTML class Attribute? - 12 (+@ How to use class attributes in javascript?) (0) | 2021.07.28 |
댓글