Menu
CoddyTech

映画リスト

CoddyのHTMLジャーニー「CSSによるスタイリング」セクションの一部。レッスン 74/76。

 

challenge icon

チャレンジ

簡単

4枚の映画カードをスタイル設定し、縦に並べましょう。最終的なデザインは以下の画像のようになりますが、色は自由に選んでください。

以下の手順に従ってください。

  1. display: flex; flex-direction: column;を使って、映画カードを縦に並べます。
  2. justify-content: center;を使って、列を垂直方向の中央に配置します。
  3. align-items: center;を使って、カードを適切に配置します。
  4. 各映画カードに固定サイズと柔らかな色を設定します。
  5. 各映画ボックスにmargin-bottomとpaddingを追加して、ボックス間に余白を作り、読みやすくします。
  6. box-sizing: border-boxを適用して、意図しない余白の問題を防ぎます。
  7. overflow: autoを使って、カード内の余分なテキストを処理します。

デザインをより魅力的にするために、box-shadow、border-radius、font-familyや、見出しの文字色を変えるなど、自由に工夫してみてください。

自分で試してみよう

<html>
    <head>
        <title>Movies</title>
        <link rel="stylesheet" href="styles.css">  
    </head>
    <body>
        <div class="movies">
            <div class="movie">
                <h2>King Kong (2005)</h2>
                <p>A filmmaker and his crew travel to Skull Island, where they encounter King Kong.</p>
            </div>
            <div class="movie">
                <h2>Inception (2010)</h2>
                <p>A thief who enters dreams to steal secrets faces his toughest mission yet.</p>
            </div>
            <div class="movie">
                <h2>The Matrix (1999)</h2>
                <p>A hacker learns the truth about reality and joins the fight against machines.</p>
            </div>
            <div class="movie">
                <h2>Casablanca (1942)</h2>
                <p>A nightclub owner is reunited with his lost love during World War II.</p>
            </div>
        </div>
    </body>
</html>

CSSによるスタイリングのすべてのレッスン

自分で練習してみよう: Webプレイグラウンド