복습 챌린지
Coddy HTML 여정의 실전 프론트엔드 섹션에 포함된 레슨. 35개 중 11번째.
챌린지
쉬움사용자 프로필 HTML 페이지가 주어집니다. 모바일 우선 디자인 원칙을 적용하여 페이지가 모든 화면 크기에 완전히 반응하도록 만드세요. 다음 지침을 따르세요.
1. 모바일 우선 탐색
- 큰 화면에서는 탐색 목록을 표시하고 메뉴 버튼을 숨기세요.
2. 모바일 우선 타이포그래피
- CSS 변수
--body-font-size: 16px를 만들고 body에 적용하세요. 이 값은 작은 화면의 기본 글꼴 크기가 됩니다.
3. 모바일 우선 이미지
- 모바일과 큰 화면에 서로 다른 이미지 크기를 제공하려면
<picture>태그를 사용하세요. - 큰 이미지를 가리키는
srcset과 함께<source>태그를 사용하세요. 예:https://upload.wikimedia.org/wikipedia/commons/1/1f/Woman_1.jpg. - 큰 화면에 적용하려면
media="(min-width: 768px)"를 추가하세요. - 프로필 이미지가 반응형으로 표시되도록 유지하세요.
width: 100%와max-width: 250px를 지정하면 좁은 화면에서 이미지가 줄어듭니다. 넓은 화면에서는 이미지가 250px로 유지되며, 더 큰 소스를 사용하면 이미지가 더 선명해집니다.
4. 모바일 우선 양식
- 모든 입력 필드와 제출 버튼의 너비를
100%로 설정하여 전체 너비를 차지하고 쉽게 누를 수 있도록 하세요.
모바일과 데스크톱 화면 모두에서 페이지가 깔끔하고 읽기 쉬우며 사용하기 편리해야 합니다. 간격, 정렬, 반응형 크기를 적용하여 모든 요소가 균형 있게 보이도록 하세요.
직접 해보기
<!DOCTYPE html>
<html>
<head>
<title>Mobile-First Profile</title>
<style>
:root {
--primary-font: Arial, sans-serif;
--heading-font: 'Helvetica', sans-serif;
--h1-size: 2rem;
--h2-size: 1.5rem;
--primary-color: #4a90e2;
--secondary-color: #f0f4f8;
}
body {
font-family: var(--primary-font);
margin: 0;
padding: 20px;
background-color: var(--secondary-color);
}
h1 {
font-family: var(--heading-font);
font-size: var(--h1-size);
color: var(--primary-color);
margin-bottom: 5px;
}
h2 {
font-family: var(--heading-font);
font-size: var(--h2-size);
color: #333;
margin-top: 0;
}
nav {
margin-bottom: 20px;
}
.menu-button {
display: block;
padding: 10px 15px;
background-color: var(--primary-color);
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
margin-bottom: 10px;
}
.nav-list {
display: none;
list-style: none;
padding: 0;
margin: 0;
}
.nav-list li {
margin-bottom: 10px;
}
.nav-list li a {
text-decoration: none;
color: var(--primary-color);
}
.profile-img {
width: 100%;
max-width: 250px;
border-radius: 50%;
margin-bottom: 20px;
display: block;
}
section p {
line-height: 1.6;
margin-bottom: 20px;
}
form {
display: flex;
flex-direction: column;
gap: 10px;
}
input, textarea, button {
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 1rem;
}
button {
background-color: var(--primary-color);
color: white;
cursor: pointer;
}
/* Media queries for larger screens */
@media (min-width: 768px) {
.nav-list {
gap: 20px;
}
.nav-list li {
margin-bottom: 0;
}
form {
max-width: 500px;
}
}
</style>
</head>
<body>
<nav>
<button class="menu-button">Menu</button>
<ul class="nav-list">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<header>
<h1>Jane Doe</h1>
<h2>Web Developer & Designer</h2>
</header>
<section>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/1f/Woman_1.jpg/250px-Woman_1.jpg" alt="Profile Image" class="profile-img">
</section>
<section>
<p>Welcome to my profile! I specialize in creating mobile-first, responsive websites that look great on any device. My focus is on performance, accessibility, and clean design.</p>
</section>
<section>
<form>
<input type="text" placeholder="Your Name">
<input type="email" placeholder="Your Email">
<textarea placeholder="Your Message"></textarea>
<button type="submit">Send Message</button>
</form>
</section>
</body>
</html>
실전 프론트엔드의 모든 레슨
직접 연습해 보세요: Web 플레이그라운드