Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ チャレンジ:Flexboxを使用したショップカードレイアウトの作成 | Flexboxによるモダンレイアウト
CSSの基礎

bookチャレンジ:Flexboxを使用したショップカードレイアウトの作成

メニューを表示するにはスワイプしてください

Flexbox の機能を活用して、商品画像、説明文、価格を含むショップカードの作成。デフォルトでは、すべての要素が縦に積み重なって表示される構造。しかし、flexbox を使用してこの挙動を変更することが目標。

次の HTML 構造を参照:

<div class="shopping-card">
  <img src="link-to-image" alt="Analytics Machine" class="product-image" />
  <div class="product-info">
    <h3 class="product-title">Analytics Machine</h3>
    <p class="product-description">Bio Innovation</p>
    <div class="product-price">$10.00</div>
    <button class="add-to-cart">Add to Cart</button>
  </div>
</div>

課題は、以下を達成するために CSS を修正すること:

  • 商品画像(img クラス付きの product-image タグ)と商品情報(div クラス付きの product-info タグ)の両方を含む親要素を特定。
  • 特定した親要素(div クラス付きの shopping-card タグ)に flexbox を適用。
  • ショッピングカード内のアイテムを垂直方向に中央揃え。
index.html

index.html

index.css

index.css

copy
  • 親要素である display: flex; クラスに shopping-card を適用。
  • デフォルトのフレックス方向は row のため、flex-direction プロパティの値を変更する必要はなし。
  • アイテムを垂直方向に中央揃えにするには、align-items: center; を使用。
index.html

index.html

index.css

index.css

copy
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 4.  6

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 4.  6
some-alt