复习挑战
本课属于 Coddy HTML 学习旅程的“精通 CSS”单元。第 25 课,共 43 课。
挑战
简单在这个挑战中,你将创建一个外观简洁又现代的咖啡店网页。这是一个练习所学内容的好机会,包括渐变、CSS 滤镜、变换和过渡效果。
你需要完成以下任务:
- 为主视觉区域的背景应用线性渐变。颜色可以任意选择。
- 鼠标悬停时,让 CTA 按钮稍微旋转,使用
transform: rotate(-3deg),并添加平滑的过渡效果。 - 在默认状态下,为咖啡图片应用滤镜
sepia(60%)。 - 鼠标悬停时,将咖啡图片的滤镜改为
sepia(0%),并使用transform: scale(1.1)将图片放大。
亲手试试
<html>
<head>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
text-align: center;
}
/* Hero Section with Gradient */
.hero {
padding: 80px 20px;
color: #3e2723;
}
.hero h1 {
font-size: 3rem;
margin-bottom: 10px;
}
.hero p {
font-size: 1.2rem;
margin-bottom: 20px;
}
.cta-btn {
background-color: #8d6e63;
color: white;
padding: 12px 24px;
border-radius: 8px;
font-size: 1rem;
}
/* Gallery section */
.gallery {
padding: 50px 20px;
background: #fffaf0;
}
.gallery h2 {
margin-bottom: 20px;
font-size: 2rem;
color: #4e342e;
}
.coffee-img {
max-width: 300px;
border-radius: 12px;
}
/*Add your CSS here */
</style>
</head>
<body>
<header class="hero">
<h1>Welcome to Coffee Bliss</h1>
<p>Your daily dose of joy in a cup</p>
<button class="cta-btn">Order Now</button>
</header>
<section class="gallery">
<h2>Our Signature Blend</h2>
<img src="https://images.unsplash.com/photo-1509042239860-f550ce710b93?auto=format&fit=crop&w=600&q=80" alt="Cup of Coffee" class="coffee-img" />
</section>
</body>
</html>
精通 CSS中的所有课
自己练习: Web 在线编辑器