Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Apply Flexbox Concepts | Section
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
CSS Fundamentals for React Developers - 1768407374224

bookChallenge: Apply Flexbox Concepts

Let's explore the power of flexbox by creating a shop card with a product image, some description, and the price. By default, all the elements are stacked in a column, one below the other. However, our goal is to change this behavior using flexbox.

Task

Consider the following HTML structure:

<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>

The task is to modify the CSS to achieve the following:

  • Identify the parent element containing both the product image (img tag with the product-image class) and product information (div tag with the product-info class).
  • Apply flexbox to the identified parent element (the div tag with the shopping-card class).
  • Vertically center the items within the shopping card.
index.html

index.html

index.css

index.css

copy
  • Apply display: flex; to the parent element with the class shopping-card.
  • The default flex direction is row, so there is no need to change the value of the flex-direction property.
  • To center items vertically, use align-items: center;.
index.html

index.html

index.css

index.css

copy
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 32

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

bookChallenge: Apply Flexbox Concepts

Sveip for å vise menyen

Let's explore the power of flexbox by creating a shop card with a product image, some description, and the price. By default, all the elements are stacked in a column, one below the other. However, our goal is to change this behavior using flexbox.

Task

Consider the following HTML structure:

<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>

The task is to modify the CSS to achieve the following:

  • Identify the parent element containing both the product image (img tag with the product-image class) and product information (div tag with the product-info class).
  • Apply flexbox to the identified parent element (the div tag with the shopping-card class).
  • Vertically center the items within the shopping card.
index.html

index.html

index.css

index.css

copy
  • Apply display: flex; to the parent element with the class shopping-card.
  • The default flex direction is row, so there is no need to change the value of the flex-direction property.
  • To center items vertically, use align-items: center;.
index.html

index.html

index.css

index.css

copy
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 32
some-alt