Menu
CoddyTech

卡片布局

本课属于 Coddy HTML 学习旅程的“精通 CSS”单元。第 29 课,共 43 课。

challenge icon

挑战

简单

在本课中,你将通过添加背景、边框、内边距,并调整图标和标题的大小,为单张卡片设置样式。你还会为卡片添加圆角和间距,让它们看起来更精致。

你的 CSS 挑战:

  1. 为 .feature 类设置样式,为每张卡片添加白色背景、内边距和圆角。
  2. 设置边框,并调整每张卡片的宽度。
  3. 为 .feature 类中的 .icon 设置样式,调整字体大小并添加底部外边距。
  4. 为 h3 标签设置样式,调整文本颜色,并在标题下方添加间距。该标签位于 .feature中。

亲手试试

<html>
<head>
  <title>Hobby Club Landing Page</title>
  <link rel="stylesheet" href="styles.css">
</head>
<body>
    
  <header class="hero">
      <div class="container">
        <h1>Welcome to Hobby Club</h1>
        <p>Find your passion. Join a community. Grow your skills.</p>
        <a href="#" class="btn">Get Started</a>
      </div>
  </header>

  <section class="features">
    <h2 class="section-title">Popular Clubs</h2>
    <div class="cards">
      <div class="feature">
        <div class="icon"><img src="https://upload.wikimedia.org/wikipedia/commons/f/fa/Android_Emoji_1f4f7_red.svg" width="20px"></div>
        <h3>Photography</h3>
        <p>Capture the moment and share your perspective.</p>
      </div>
      <div class="feature">
        <div class="icon"><img src="https://upload.wikimedia.org/wikipedia/commons/5/51/Emoji_u1f3a8.svg" width="20px"></div>
        <h3>Art & Design</h3>
        <p>Draw, paint, and bring your creative ideas to life.</p>
      </div>
      <div class="feature">
        <div class="icon"><img src="https://upload.wikimedia.org/wikipedia/commons/e/e6/Emoji_u1f3ae.svg" width="20px"></div>
        <h3>Gaming</h3>
        <p>Connect with fellow gamers and play your favorite titles.</p>
      </div>
    </div>
  </section>

</body>
</html>

精通 CSS中的所有课

自己练习: Web 在线编辑器