Menu
Coddy logo textTech

ヘッダーセクションのスタイル設定

CoddyのHTMLジャーニー「CSS Mastery」セクションの一部 — レッスン 26/43。

challenge icon

チャレンジ

簡単

このミニプロジェクトでは、CSSのみを使用して、楽しい趣味のランディングページを完成させます。

HTMLはすでに作成されています。あなたの仕事は、本物のフロントエンドエンジニアのように、ステップバイステップでスタイルを適用することです。これは、実務的なレイアウト、ボタン、スタイリングのテクニックを練習するのに最適な方法です!

最後に作成するもののプレビューはこちらです:

screenshot landing.png

最初のチャレンジでは、ページの上部、つまりヘッダー(「ヒーロー」セクションとも呼ばれます)のスタイリングから始めます。今は、ただのテキストが一番上に置かれているだけです。あなたの目標は、これをクリーンで目を引くページの導入部に変えることです。

CSSチャレンジの内容:

  1. デフォルトの余白を削除する:bodymargin: 0を設定し、背景色を追加します。
  2. .heroセクションに背景色(rgb(30, 207, 104))と50pxのパディングを設定します。
  3. .heroにFlexboxを使用して、すべてを中央に配置します:
    1. display: flex
    2. flex-direction: column
    3. align-items: center
    4. justify-content: center
    5. text-align: center
  4. .hero h1.hero pを使用してテキストのスタイルを設定します。

トップセクションがクリーンで目を引くように仕上げてください。

自分で試してみよう

<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 Masteryのすべてのレッスン