Problem: Adaptive Profile Card
Problem description
Given a <div class="profile-card"> containing an <img class="avatar">, a <h3> for the username, and a <p> for the bio, write CSS so the card:
Displays vertically stacked (
avatar,heading, andparagraph) when its containerinline sizeis <250px.Displays horizontally (
avatarleft,textright) with0.875remh3font wheninline sizeis ≥250pxbut <500px.Displays horizontally with larger spacing and a
1.25remh3font wheninline sizeis ≥500px.Ensures the
avataris always square (aspect-ratio: 1 / 1) and covers its allotted space.
Goal
Implement CSS in styles.css to:
Declare
container-type: inline-sizeandcontainer-name: profileon.profile-card.Use
@containerqueries at250pxand500pxto adjust flex direction, spacing, and typography.Apply
aspect-ratioandobject-fit: coveron the avatar image.
Constraints
Do not modify the HTML structure.
Use only CSS (no JavaScript is allowed).
Breakpoints must be exactly at
250pxand500px.Avatar must maintain a 1:1 aspect ratio and cover its container.
Heading font-size must be
1remby default,0.875rembetween250px–499px, and1.25remat ≥500px.
Sample visual output
Here’s what the output would look like:
Good luck trying the problem! If you’re unsure how to proceed, check the Solution.
Problem: Adaptive Profile Card
Problem description
Given a <div class="profile-card"> containing an <img class="avatar">, a <h3> for the username, and a <p> for the bio, write CSS so the card:
Displays vertically stacked (
avatar,heading, andparagraph) when its containerinline sizeis <250px.Displays horizontally (
avatarleft,textright) with0.875remh3font wheninline sizeis ≥250pxbut <500px.Displays horizontally with larger spacing and a
1.25remh3font wheninline sizeis ≥500px.Ensures the
avataris always square (aspect-ratio: 1 / 1) and covers its allotted space.
Goal
Implement CSS in styles.css to:
Declare
container-type: inline-sizeandcontainer-name: profileon.profile-card.Use
@containerqueries at250pxand500pxto adjust flex direction, spacing, and typography.Apply
aspect-ratioandobject-fit: coveron the avatar image.
Constraints
Do not modify the HTML structure.
Use only CSS (no JavaScript is allowed).
Breakpoints must be exactly at
250pxand500px.Avatar must maintain a 1:1 aspect ratio and cover its container.
Heading font-size must be
1remby default,0.875rembetween250px–499px, and1.25remat ≥500px.
Sample visual output
Here’s what the output would look like:
Good luck trying the problem! If you’re unsure how to proceed, check the Solution.