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 | Mastering Flexbox for Layouts
CSS Fundamentals
course content

Kursusindhold

CSS Fundamentals

CSS Fundamentals

1. Getting Started with CSS
2. Styling Text in CSS
3. The CSS Box Model & Spacing Elements
4. Mastering Flexbox for Layouts
5. Adding Decorative Effects with CSS

book
Challenge: 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:

html

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.

html

index.html

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

html

index.html

css

index.css

copy

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 4. Kapitel 6

Spørg AI

expand
ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

course content

Kursusindhold

CSS Fundamentals

CSS Fundamentals

1. Getting Started with CSS
2. Styling Text in CSS
3. The CSS Box Model & Spacing Elements
4. Mastering Flexbox for Layouts
5. Adding Decorative Effects with CSS

book
Challenge: 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:

html

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.

html

index.html

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

html

index.html

css

index.css

copy

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 4. Kapitel 6
Vi beklager, at noget gik galt. Hvad skete der?
some-alt