Problem: Adaptive Card Component
Problem description
Given a <div class="card"> containing an <img> and a .content <div> with heading and paragraph, write CSS so the card:
Displays in a single column (image on top) when its container width is less than
800px.Displays in two columns (image left, content right) when container width is at least
800px.Uses responsive font sizes for the heading at each breakpoint.
Ensures the image preserves a 4:3 aspect ratio and fills its container area.
Goal
Implement CSS in styles.css to:
Declare
container-typeon the card.Use
@containerqueries at300pxto adjust layout and typography.Apply
aspect-ratioandobject-fit: coveron the image.
Constraints
Do not modify the HTML structure.
Use only CSS (no JavaScript is allowed).
Card must adapt layout exactly at the
300pxthreshold.Image aspect ratio must be 4:3.
Heading font-size must be
0.875rembelow300pxand1.25remat or above300px.
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 Card Component
Problem description
Given a <div class="card"> containing an <img> and a .content <div> with heading and paragraph, write CSS so the card:
Displays in a single column (image on top) when its container width is less than
800px.Displays in two columns (image left, content right) when container width is at least
800px.Uses responsive font sizes for the heading at each breakpoint.
Ensures the image preserves a 4:3 aspect ratio and fills its container area.
Goal
Implement CSS in styles.css to:
Declare
container-typeon the card.Use
@containerqueries at300pxto adjust layout and typography.Apply
aspect-ratioandobject-fit: coveron the image.
Constraints
Do not modify the HTML structure.
Use only CSS (no JavaScript is allowed).
Card must adapt layout exactly at the
300pxthreshold.Image aspect ratio must be 4:3.
Heading font-size must be
0.875rembelow300pxand1.25remat or above300px.
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.