복습 도전 과제
Coddy HTML 여정의 CSS로 스타일링하기 섹션에 포함된 레슨. 76개 중 60번째.
챌린지
쉬움이제 relative, absolute, fixed, z-index를 비롯한 CSS의 다양한 위치 지정 기법을 배웠으니, 종합적인 도전 과제로 배운 내용을 시험해 볼 차례입니다. 이 과제를 통해 이러한 속성을 함께 사용하여 복잡하고 동적인 레이아웃을 만드는 방법에 대한 이해를 확고히 할 수 있습니다. 각 위치 지정 방식을 배운 내용을 적용하여 특정 디자인을 재현해 보세요.
피자 레스토랑 웹사이트의 HTML 문서가 주어집니다. CSS 위치 지정 속성을 사용해 다음 요소의 스타일을 지정하고 깔끔하고 정돈된 레이아웃을 만드세요.
아래 단계를 따르세요.
- 헤더 스타일 지정:
<header>요소를 대상으로 지정하세요.- position을
fixed로 설정하여 페이지 상단에 고정되게 하세요. - 페이지 전체 너비를 차지하도록 top을
0, left를0, width를100%로 설정하세요. - 헤더가 페이지의 다른 요소 위에 표시되도록 z-index를
10으로 설정하세요.
- 메뉴 섹션 스타일 지정:
.menu클래스를 대상으로 지정하세요.- 문서 흐름에서의 기본 위치를 기준으로 배치할 수 있도록 position을
relative로 설정하세요.
- 프로모션 상자 스타일 지정:
.promotions클래스를 대상으로 지정하세요..menu섹션을 기준으로 배치하도록 position을absolute로 설정하세요.- 메뉴의 오른쪽 위쪽에 배치하도록 top을
100px, right를20px로 설정하세요. - 헤더 아래에 표시되면서 메뉴의 다른 콘텐츠 위에 표시되도록 z-index를
5로 설정하세요.
직접 해보기
<html>
<head>
<title>Pizza Restaurant</title>
<style>
/* Fixed Header */
header {
background-color: #ff6f61;
padding: 20px;
text-align: center;
font-size: 24px;
color: white;
}
/* Menu Section (Relative) */
.menu {
margin-top: 70px; /* Space for fixed header */
padding: 20px;
background-color: #f8f8f8;
font-size: 18px;
}
/* Promotions Box (Absolute) */
.promotions {
background-color: #ffdf00;
padding: 10px;
font-size: 20px;
border-radius: 10px;
}
</style>
</head>
<body>
<!-- 고정 헤더 -->
<header>
Pizza Restaurant
</header>
<!-- 메뉴 섹션 -->
<div class="menu">
<h2>Our Menu</h2>
<ul>
<li>Margherita</li>
<li>Pepperoni</li>
<li>Veggie</li>
<li>Hawaiian</li>
</ul>
<p>Order now and enjoy!</p>
<!-- 프로모션 상자 -->
<div class="promotions">
<p>Get 20% off your first order!</p>
</div>
</div>
<div class="pizza-info">
<h2>About Pizza</h2>
<p>Pizza, a dish with origins in Italy, is one of the world's most beloved foods. It was first made in Naples during the 18th century, with the classic Margherita pizza being named after Queen Margherita of Savoy. The traditional pizza is known for its simple ingredients: a thin crust, tomato sauce, mozzarella cheese, and fresh basil.</p>
<p>Over the years, pizza has evolved into a variety of regional styles, from thin-crust New York-style pizza to deep-dish Chicago pizza. While the toppings have diversified, the tradition of sharing a pizza with family and friends remains an essential part of the pizza experience.</p>
<p>In Italy, pizza is often enjoyed casually, typically paired with a glass of wine or soda. It is a symbol of Italian culture, and many believe that a good pizza is a representation of the country's culinary expertise and passion for food.</p>
<p>Pizza's global reach has led to many variations and adaptations in different countries. In Japan, for example, toppings like teriyaki chicken and squid are popular, while in Brazil, green peas and corn are commonly found on pizzas. In the United States, pizza has become a staple of fast food, with different regions offering their unique twists, such as the deep-dish pizza from Chicago and the thin crust of New York City.</p>
</div>
</body>
</html>CSS로 스타일링하기의 모든 레슨
직접 연습해 보세요: Web 플레이그라운드