현우의 개발상자
멋쟁이사자 FE7 16일차 본문
728x90
Apply(적용)
3주간 배운 html&css를 통하여 자판기 페이지를 만들어 봤다.
<!DOCTYPE html>
<html lang="ko-KR">
<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>밴딩 머신</title>
<link rel="stylesheet" href="./banding.css" />
</head>
<body>
<div class="header"></div>
<div class="main">
<div class="box1">
<div class="box1_top">
<div class="item1">
<div class="can"></div>
<p class="canName">Original Cola</p>
<div class="canPrice">1000원</div>
</div>
<div class="item2">
<div class="can"></div>
<p class="canName">violet Cola</p>
<div class="canPrice">1000원</div>
</div>
<div class="item3">
<div class="can"></div>
<p class="canName">Yellow Cola</p>
<div class="canPrice">1000원</div>
</div>
<div class="item4">
<div class="can"></div>
<p class="canName">Cool Cola</p>
<div class="canPrice">1000원</div>
</div>
<div class="item5">
<div class="can"></div>
<p class="canName">Green Cola</p>
<div class="canPrice">1000원</div>
</div>
<div class="item6">
<div class="can"></div>
<p class="canName">Orange Cola</p>
<div class="canPrice">1000원</div>
</div>
</div>
<div class="box1_bottom">
<div class="bottom_item1">
<p class="a">잔액</p>
<p>1,000원</p>
</div>
<div class="bottom_item2">거스름돈 반환</div>
<input class="bottom_item3" placeholder="입금액 입력"></input>
<div class="bottom_item4">입금</div>
<div class="bottom_item5">
<div class="shoppinglist one">
<div class="imgName">
<img src="./img/coke1.png" alt=""><p>Original_Cola</p>
</div>
<div class="number">1</div>
</div>
<div class="shoppinglist two">
<div class="imgName">
<img src="./img/coke5.png" alt=""><p>Green_Coke </p>
</div>
<div class="number">2</div>
</div>
</div>
<button class="bottom_item6">획득</button>
</div>
</div>
<div class="box2">
<div class="possessedMoney">
<p class="a">소지금</p>
<p>25,000원</p>
</div>
</div>
<div class="box3">
<h3>획득한 음료</h3>
<div class="box3Items">
<div class="shoppinglist one">
<div class="imgName">
<img src="./img/coke1.png" alt=""><p>Original_Cola</p>
</div>
<div class="number">1</div>
</div>
<div class="shoppinglist two">
<div class="imgName">
<img src="./img/coke5.png" alt=""><p>Original_Cola</p>
</div>
<div class="number">2</div>
</div>
<div class="shoppinglist three">
<div class="imgName">
<img src="./img/coke6.png" alt=""><p>Original_Cola</p>
</div>
<div class="number">1</div>
</div>
<div class="shoppinglist four">
<div class="imgName">
<img src="./img/coke2.png" alt=""><p>Original_Cola</p>
</div>
<div class="number">5</div>
</div>
</div>
<p>총금액 : 9,000 원</p>
</div>
</div>
</body>
</html>
@import url(//fonts.googleapis.com/earlyaccess/notosanskr.css);
.notosanskr * {
font-family: "Noto Sans KR", sans-serif;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: Noto Sans KR;
}
button:enabled {
cursor: pointer;
}
body {
background-color: #eae8fe;
display: flex;
flex-direction: column;
align-items: center;
gap: 43px;
}
.header {
width: 436px;
height: 204px;
background: url(./img/logo.png) no-repeat 0 0 / cover;
}
.main {
width: 748px;
height: 545px;
display: grid;
grid-template-areas:
"a a a b b b"
"a a a c c c"
"a a a c c c"
"a a a c c c"
"a a a c c c"
"a a a c c c"
"a a a c c c";
gap: 16px;
}
.main div {
background-color: white;
}
.box1 {
width: 360px;
height: 545px;
grid-area: a;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 18px;
}
.box1 .box1_top {
display: grid;
grid-template-columns: repeat(3, 94px);
grid-template-rows: 135px 135px;
gap: 12px;
}
.box1_top div {
border: 1px solid #b5b5b6;
border-radius: 10px;
box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.5);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 5px;
}
.box1_top .item1 {
border-radius: 10px;
border: 3px solid var(--blue, #6327fe);
}
.box1_top .item2 {
position: relative;
}
.box1_top .item2::after {
position: absolute;
content: "";
width: 94px;
height: 135px;
border-radius: 10px;
background-color: black;
opacity: 0.7;
}
.box1_top .item2::before {
position: absolute;
content: "품절";
width: 45px;
height: 21px;
transform: rotate(-17.965deg);
flex-shrink: 0;
border: 5px double white;
z-index: 100;
display: flex;
justify-content: center;
align-items: center;
color: #eae8fe;
font-size: 14px;
font-weight: 900;
}
.box1_top .item5 {
border-radius: 10px;
border: 3px solid var(--blue, #6327fe);
}
.box1_top .item1 .can {
width: 36px;
height: 65px;
flex-shrink: 0;
background: url(./img/coke1.png);
}
.box1_top .item2 .can {
width: 36px;
height: 65px;
flex-shrink: 0;
background: url(./img/coke2.png) no-repeat 0 0 / cover;
}
.box1_top .item3 .can {
width: 36px;
height: 65px;
flex-shrink: 0;
background: url(./img/coke3.png);
}
.box1_top .item4 .can {
width: 36px;
height: 65px;
flex-shrink: 0;
background: url(./img/coke4.png);
}
.box1_top .item5 .can {
width: 36px;
height: 65px;
flex-shrink: 0;
background: url(./img/coke5.png);
}
.box1_top .item6 .can {
width: 36px;
height: 65px;
flex-shrink: 0;
background: url(./img/coke6.png);
}
.box1_top div .canName {
color: var(--gray-1, #333);
font-size: 9px;
font-weight: 500;
}
.box1_top div .canPrice {
width: 70px;
height: 22px;
flex-shrink: 0;
border-radius: 50px;
background: var(--blue, #6327fe);
color: #fff;
font-family: Noto Sans KR;
font-size: 12px;
font-style: normal;
font-weight: 500;
}
.box1 .box1_bottom {
display: grid;
grid-template-areas:
"a a b"
"c c d"
"e e f"
"e e f"
"e e f";
gap: 13px;
}
.box1_bottom .bottom_item1 {
width: 200px;
height: 33px;
border-radius: 6px;
background-color: #eae8fe;
grid-area: a;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 10px;
}
.bottom_item1 p {
position: relative;
color: #000;
font-size: 14px;
font-weight: 500;
line-height: normal;
}
.bottom_item1 .a::after {
position: absolute;
content: ":";
font-size: 12px;
top: 3.5px;
left: 30px;
}
.box1_bottom .bottom_item2 {
width: 94px;
height: 33px;
background: #fff;
border-radius: 6px;
border: 1px solid #b5b5b6;
box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.5);
grid-area: b;
display: flex;
justify-content: center;
align-items: center;
color: #000;
font-size: 12px;
font-weight: 500;
}
.box1_bottom .bottom_item3 {
display: block;
width: 200px;
height: 33px;
border-radius: 6px;
border: 1px solid #b5b5b6;
grid-area: c;
padding-left: 5px;
}
.box1_bottom .bottom_item3::placeholder {
color: var(--gray-4, #bdbdbd);
font-family: Noto Sans KR;
font-size: 13px;
font-weight: 500;
line-height: normal;
}
.box1_bottom .bottom_item4 {
width: 94px;
height: 33px;
border-radius: 6px;
border: 1px solid #b5b5b6;
box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.5);
grid-area: d;
display: flex;
justify-content: center;
align-items: center;
color: #000;
font-size: 13px;
font-weight: 600;
}
.box1_bottom .bottom_item5 {
background: #eae8fe;
height: 106px;
border-radius: 6px;
grid-area: e;
display: flex;
padding: 0 0 2px 0;
flex-direction: column;
justify-content: flex-end;
align-items: center;
gap: 5px;
}
.bottom_item5 .shoppinglist {
width: 170px;
height: 46px;
flex-shrink: 0;
border-radius: 5px;
background: #fff;
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
}
.shoppinglist .imgName {
width: 18px;
height: 33px;
flex-shrink: 0;
display: flex;
align-items: center;
color: var(--gray-1, #333);
font-size: 9px;
font-weight: 700;
}
.shoppinglist .imgName img {
width: 18px;
height: 33px;
flex-shrink: 0;
margin-right: 8px;
}
.shoppinglist .number {
width: 30px;
height: 30px;
flex-shrink: 0;
border-radius: 5px;
border: 1px solid var(--gray-4, #bdbdbd);
display: flex;
justify-content: center;
align-items: center;
color: #000;
text-align: center;
font-size: 14px;
font-style: normal;
font-weight: 500;
line-height: normal;
}
.box1_bottom .bottom_item6 {
width: 94px;
height: 106px;
border-radius: 6px;
grid-area: f;
border: none;
background: #6327fe;
box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
display: flex;
justify-content: center;
align-items: center;
color: #fff;
font-family: Noto Sans KR;
font-size: 13px;
font-style: normal;
font-weight: 500;
line-height: normal;
}
.box2 {
width: 360px;
height: 50px;
flex-shrink: 0;
grid-area: b;
display: flex;
justify-content: center;
align-items: center;
}
.box2 .possessedMoney {
background-color: #eae8fe;
width: 306px;
height: 32px;
border-radius: 6px;
padding-left: 5px;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 7px;
}
.box2 .possessedMoney p {
position: relative;
color: #000;
font-size: 14px;
font-weight: 500;
}
.box2 .possessedMoney .a::after {
position: absolute;
content: ":";
font-size: 15px;
top: -1.5px;
left: 47px;
}
.box3 {
width: 360px;
height: 474px;
grid-area: c;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.box3 h3 {
color: #000;
text-align: center;
font-family: Noto Sans KR;
font-size: 14px;
font-style: normal;
font-weight: 700;
line-height: normal;
}
.box3 .box3Items {
width: 306px;
height: 364px;
flex-shrink: 0;
background: #eae8fe;
margin-top: 16px;
margin-bottom: 8px;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
padding-top: 16px;
gap: 7px;
}
.box3Items .shoppinglist {
width: 276px;
height: 46px;
flex-shrink: 0;
border-radius: 5px;
background: #fff;
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
}
.box3Items .shoppinglist .imgName {
width: 18px;
height: 33px;
flex-shrink: 0;
display: flex;
align-items: center;
color: var(--gray-1, #333);
font-size: 9px;
font-weight: 500;
}
.box3Items .shoppinglist .imgName img {
width: 18px;
height: 33px;
flex-shrink: 0;
margin-right: 8px;
}
.box3Items .shoppinglist .number {
width: 30px;
height: 30px;
flex-shrink: 0;
border-radius: 5px;
border: 1px solid var(--gray-4, #bdbdbd);
display: flex;
justify-content: center;
align-items: center;
color: #000;
font-size: 20px;
font-weight: 500;
}
.box3 p {
width: 306px;
color: #000;
font-size: 12px;
font-weight: 500;
display: flex;
justify-content: flex-end;
}
@media (max-width: 700px) {
body {
background-color: white;
gap: 0;
}
.header {
width: 166px;
height: 71.119px;
flex-shrink: 0;
}
.main {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
gap: 0;
}
.box2 {
height: 25px;
margin-bottom: 20px;
}
}
WIDTH ~ 700PX 까지 보여지는 화면
Feeling(느낀 점)
미디어쿼리(@media)를 통해서 max-width 700px 까지는 작은 화면에서도 조금 더 편하게 볼 수 있게 레이아웃을 구성해 봤다. 하지만 생각만큼 내가 원하는 구도로 나오지 않았다. 왜 인지 살펴보니 자판기를 담은 div의 높이가 자판기들 다 담기에는 부족한 높이 값을 가졌기 때문에 생기는 문제였다. 그래서 높이값에 height: 100%을 주니까 문제가 해결됐다. 높이값을 지정했기 때문에 생긴 문제였다. 이번 경험을 통해는 다음번 이런 문제가 생겼을 경우, 유연하게 대처할 수 있다고 생각한다.
'멋쟁이사자 FE7' 카테고리의 다른 글
멋쟁이사자 FE7 18일차 (0) | 2023.07.26 |
---|---|
멋쟁이사자 FE7 17일차 (0) | 2023.07.25 |
멋쟁이사자 FE7 15일차 (0) | 2023.07.21 |
멋쟁이사자 FE7 14일차 (0) | 2023.07.20 |
멋쟁이사자 FE7 13일차 (0) | 2023.07.19 |