HTML
<!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>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>The Best Colors</h1>
<section>
<div>
<div class="color">
<h2>Tomato <br>#008080 </h2>
</div>
</div>
<div>
<div class="color">
<h2>Teal <br>#FF6347 </h2>
</div>
</div>
<div>
<div class="color">
<h2>Burlywood <br>#DEB887 </h2>
</div>
</div>
<div>
<div class="color">
<h2>Thistle <br>#D7BFD7 </h2>
</div>
</div>
</section>
</body>
</html>
CSS
html, body{
background-color: whitesmoke;
height:100%;
margin:0;
}
h1{
text-align: center;
}
section{
display:flex;
flex-direction: row;
justify-content: center;
flex-wrap: wrap;
position: relative;
}
div{
width: 250px;
height: 400px;
border: 10px solid white;
margin:20px;
position: relative;
}
div:first-child{
background-color: tomato;
}
div:nth-child(2){
background-color: teal;
}
div:nth-child(3){
background-color: burlywood;
}
div:nth-child(4){
background-color: thistle;
}
div.color{
background-color: white;
position: absolute;
width:240px;
height: 100px;
margin:0px;
top:20px;
left:0px;
border: 10px solid white;
text-align: left;
}
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>repl.it</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>The Best Colors</h1>
<section>
<article class="color">
<div class="color__bg"></div>
<div class="color__info">
<h3>Tomato</h3>
<h5>#FF6347</h5>
</div>
</article>
<article class="color">
<div class="color__bg"></div>
<div class="color__info">
<h3>Teal</h3>
<h5>#008080</h5>
</div>
</article>
<article class="color">
<div class="color__bg"></div>
<div class="color__info">
<h3>Burlywood</h3>
<h5>#DEB887</h5>
</div>
</article>
<article class="color">
<div class="color__bg"></div>
<div class="color__info">
<h3>Thistle</h3>
<h5>#D7BFD7</h5>
</div>
</article>
</section>
</body>
</html>
CSS
body {
height:100vh;
background-color: whitesmoke;
display: flex;
flex-direction: column;
align-items: center;
}
h1 {
margin-bottom: 50px;
}
section {
width:50%;
margin:0 auto;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.color {
width: 48%;
position: relative;
margin-bottom: 20px;
}
.color:first-child .color__bg {
background-color: tomato;
}
.color:nth-child(2) .color__bg {
background-color: teal;
}
.color:nth-child(3) .color__bg {
background-color: burlywood;
}
.color:last-child .color__bg {
background-color:thistle;
}
.color__bg {
height: 300px;
border:5px solid white;
}
.color__info {
position: absolute;
width:100%;
background-color:white;
top:20px;
padding:0px 10px;
box-sizing: border-box;
}
https://replit.com/@mimkong/ElasticLightblueMicroprogramming#style.css
flex-wrap: wrap
을 선언한다면, flex를 선언한 영역을 벗어날 경우 행을 나눠서 배치하게 됩니다.wrap-reverse
값은 행을 나눠서 배치하되, 위로 나뉩니다.flex-wrap: wrap
의 경우, 1 2 3 4
3 4
1 2
의 순서로 행이 나뉩니다.:nth-child(n)
는 형제들 사이에서 n번째 요소를 선택할 수 있는 의사 선택자입니다.div:nth-child(3), #text:nth-child(4)
)h1:nth-child(2) { color: red; }
를 한다면, 어떠한 글자도 빨간색이 되지 않습니다. 왜냐하면 h1이면서 형제들 중 2번째인 요소는 없기 때문이죠.span:nth-child(1) { color: green; }
도 마찬가지입니다.:nth-of-type(n)
을 사용하면 됩니다.h1:nth-type(2) { color: red; }
를 한다면, 2번째 h1에 빨간색이 적용될 것입니다.first-child
, last-child
, first-of-type
, last-of-type
을 사용하면 됩니다.https://velog.io/@kansun12/HTML3
TA's의 정답해설을 무조건 다 적을필요는 없을 것 같다...
읽어보고 내가 필요한 정보, 적지 않았던 정보만 적으면 될 것 같구 내것과 해설의 HTML, CSS를 비교하여 부족한 부분은 공부하는 방향으로 잡아야겠다
오늘은 몸이 안좋아서 여기까지..