Layout/반응형
layout - 8 (flex)
초짜코딩
2022. 4. 17. 23:30
<style>
* {
margin: 0;
}
body {
background-color: #E1F5FE;
}
#wrap {
width: 1200px;
margin: 0 auto;
}
#header {
height: 100px;
background-color: #BBDEFB;
grid-area: header;
}
#nav {
height: 100px;
background-color: #90CAF9;
}
#main {
display: flex;
}
#contents {
width: 900px;
display: flex;
flex-wrap: wrap;
}
#aside {
width: 30%;
height: 780px;
background-color: #64B5F6;
}
#article1 {
width: 100%;
height: 260px;
background-color: #42A5F5;
}
#article2 {
width: 100%;
height: 260px;
background-color: #2196F3;
}
#article3 {
width: 100%;
height: 260px;
background-color: #1E88E5;
}
#footer {
height: 100px;
background-color: #0A78DD;
}
@media (max-width: 1300px) {
#wrap {
width: 96%;
}
#article2 {
width: 50%;
height: 520px;
}
#article3 {
width: 50%;
height: 520px;
}
}
@media (max-width: 768px) {
#wrap {
width: 100%;
}
#contents {
width: 900px;
flex-direction: column;
}
#article1 {
width: 100%;
height: 390px;
}
#article2 {
width: 100%;
height: 390px;
}
#article3 {
display: none;
}
}
@media (max-width: 480px) {
#contents {
width: 900px;
flex-direction: column;
}
#aside{
display: none;
}
#article1 {
width: 100%;
height: 200px;
}
#article2 {
width: 100%;
height: 430px;
}
#article3 {
width: 100%;
height: 150px;
display: block;
}
}
</style>
<div id="wrap">
<header id="header"></header>
<nav id="nav"></nav>
<main id="main">
<aside id="aside"></aside>
<div id="contents">
<article id="article1"></article>
<article id="article2"></article>
<article id="article3"></article>
</div>
</main>
<footer id="footer"></footer>
</div>