
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
마켓컬리 클론 코딩 마무리했는데, 아래 4개 카드를 샘플처럼 한줄로 나열되게 하고 싶은데
Chat GPT한테 물어봐서 별짓을 다해도 왜 안될까요 ㅎㅎ
전체 CSS 코드 및 HTML 코드 보내드립니다. 선생님이랑 동일하게(이미지 제외) 한 것 토대로 GPT에게 해결책 물어서 수정한 버전입니다.
작성한 코드 및 에러 메세지
html,
body {
height: 100%;
}
.container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
header {
width: 1000px;
margin: 10px auto;
/* 수정 */
display: flex;
flex-direction: column;
height: 150px;
/* 높이 조정 */
}
.header-box1 {
display: flex;
justify-content: flex-end;
align-items: center;
height: 50%;
/* 높이 조정 */
}
.header-box1-right {
display: flex;
justify-content: space-between;
align-items: center;
}
.header-box1-right a {
color: #000;
text-decoration: none;
margin-left: 20px;
border-bottom: none;
}
.header-box2 {
display: flex;
justify-content: space-between;
align-items: center;
height: 50%;
/* 높이 조정 */
}
.header-box2-left img {
height: 60px;
margin-right: 20px;
}
.header-box2-left span {
font-size: 24px;
font-weight: bold;
}
.header-box2-center form {
display: flex;
align-items: center;
border: 1.5px solid #5F0080;
border-radius: 5px;
/* 모서리를 좀 덜 둥글게 */
padding: 10px;
width: 400px;
height: 30px;
/* 가로 길이를 400px로 */
}
.header-box2-center input[type="text"] {
border: none;
font-size: 16px;
margin-right: 10px;
flex-grow: 1;
/* input을 늘리기 위해 추가 */
}
.header-box2-center button[type="submit"] {
border: none;
background: none;
cursor: pointer;
}
.header-box2-center form {
border-color: #5F0080;
/* 테두리 색상 변경 */
}
.header-box2-center label {
color: #666;
/* 회색으로 변경 */
font-size: 14px;
margin-right: 10px;
}
.header-box2-right {
display: flex;
justify-content: space-between;
align-items: center;
width: 80px;
}
.header-box2-right img {
height: 30px;
}
nav {
width: 1000px;
margin: 0 auto 10px;
/* 수정 */
display: flex;
justify-content: space-between;
align-items: center;
height: 50px;
}
.nav-left {
display: flex;
align-items: center;
}
.nav-left img {
height: 30px;
margin-right: 5px;
}
.nav-left span {
font-size: 16px;
}
.nav-center {
display: flex;
justify-content: space-between;
align-items: center;
flex-grow: 1;
margin: 0 100px;
letter-spacing: -1px;
}
.nav-center a {
color: #333;
text-decoration: none;
font-size: 16px;
margin-right: 10px;
font-weight: bold;
}
.nav-right {
display: flex;
align-items: center;
}
.btn {
border: 2px solid #ccc;
border-radius: 20px;
padding: 5px 10px;
background-color: transparent;
color: #5F0080;
font-size: 14px;
font-weight: bold;
cursor: pointer;
}
.box1 {
background-color: #eee;
height: auto;
display: flex;
justify-content: center;
align-items: center;
}
.box1-content {
max-width: 100%;
text-align: center;
}
.box1-content img {
max-width: 100%;
height: auto;
}
.box1-content h2 {
color: #5f0080;
font-size: 24px;
margin-top: 20px;
margin-bottom: 10px;
}
.box1-content p {
font-size: 16px;
line-height: 1.5;
margin-bottom: 0;
}
.box2 {
width: 1000px;
margin: 0 auto;
text-align: center;
padding: 20px 0;
}
.box2-title {
color: #5f0080;
font-size: 24px;
margin-bottom: 20px;
}
.card-container {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.card {
width: calc(25% - 20px); /* 카드의 너비를 4개가 들어가도록 설정 */
border: 1px solid #ccc;
border-radius: 5px;
box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.2);
overflow: hidden;
margin-bottom: 20px;
}
.card-image {
position: relative;
height: 250px;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
}
.card-image img {
width: 100%;
height: auto;
}
.card-icon {
position: absolute;
bottom: 0;
right: 0;
background-color: rgba(95, 0, 128, 0.8);
padding: 5px;
}
.card-icon img {
width: 20px;
height: 20px;
}
.card-content {
text-align: left;
padding: 10px;
height: 100%;
box-sizing: border-box;
}
.card-content h3 {
margin: 0;
font-size: 16px;
}
.card-content p {
margin: 10px 0 0;
font-size: 14px;
font-weight: bold;
}
<!DOCTYPE html>
<html lang="ko">
<header>
<meta charset="UTF-8">
<title>My Website</title>
<link rel="stylesheet"
<link rel="stylesheet" href="07_styles.css">
<div class="header-box1">
<div class="header-box1-right">
<a href="#">회원가입</a>
<a href="#">로그인</a>
<a href="#">고객센터</a>
</div>
</div>
<div class="header-box2">
<div class="header-box2-left">
<img src="https://s3.ap-northeast-2.amazonaws.com/materials.spartacodingclub.kr/chatgpt300%25/week5/image.png"
alt="Logo" class="logo" />
<span style="color: #5F0080;">스파르타 </span>
</div>
<div class="header-box2-center">
<form>
<label for="search">검색어를 입력해주세요</label>
<input type="text" id="search" name="search">
<button type="submit">
<!-- 아래 부분 복사 붙여 넣기 -->
<span class="material-symbols-outlined">search</span>
<!-- 복사 붙여 넣기 -->
</button>
</form>
</div>
<div class="header-box2-right">
<span class="material-symbols-outlined">
location_on
</span>
<span class="material-symbols-outlined">
favorite
</span>
<span class="material-symbols-outlined">
shopping_cart
</span>
</div>
</div>
</header>
<body>
<div class="container">
<nav>
<div class="nav-left">
<span class="material-symbols-outlined"> menu </span>
<span class="category-text">카테고리</span>
</div>
<div class="nav-center">
<a href="#">신상품</a>
<a href="#">베스트</a>
<a href="#">알뜰쇼핑</a>
<a href="#">특가/혜택</a>
</div>
<div class="nav-right">
<button class="btn">샛별. 택배 배송안내</button>
</div>
</nav>
<div class="box1">
<div class="box1-content">
<!-- 변경할 부분 -->
alt="이미지" />
<!-- 변경할 부분 -->
</div>
</div>
<div class="box2">
<h2 class="box2-title">이 상품 어때요?</h2>
<div class="card-container">
<div class="card">
<div class="card-image">
alt="상품1">
<div class="card-icon">
<span class="material-symbols-outlined">
local_mall
</span>
</div>
</div>
<div class="card-icon">
<span class="material-symbols-outlined">
local_mall
</span>
</div>
</div>
<div class="card-content">
<h3>[스파르타] 몬스테라</h3>
<p>가격 : $50</p>
</div>
</div>
<div class="card-container">
<div class="card">
<div class="card-image">
alt="상품2">
<div class="card-icon">
<span class="material-symbols-outlined">
local_mall
</span>
</div>
</div>
<div class="card-content">
<h3>[스파르타] 문샤인</h3>
<p>가격 : $70</p>
</div>
</div>
</div>
<div class="card-container">
<div class="card">
<div class="card-image">
alt="상품3">
<div class="card-icon">
<span class="material-symbols-outlined">
local_mall
</span>
</div>
</div>
<div class="card-content">
<h3>[스파르타] 스투키</h3>
<p>가격 : $80</p>
</div>
</div>
</div>
<div class="card-container">
<div class="card">
<div class="card-image">
alt="상품4">
<div class="card-icon">
<span class="material-symbols-outlined">
local_mall
</span>
</div>
</div>
<div class="card-content">
<h3>[스파르타] 미모사</h3>
<p>가격 : $60</p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>오류 발생 시, 작성한 코드 전체와 에러 메시지를 첨부해 주세요.
Tip 1) </> 아이콘을 눌러 코드박스를 만들어 보세요.
Tip 2) Ctrl+A(맥의 경우 Command+A) 단축키로 코드를 한 번에 선택할 수 있어요!
