0
0
CSSmarkup~20 mins

Flex container in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
๐ŸŽ–๏ธ
Flex Container Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
โ“ layout
intermediate
2:00remaining
What is the effect of justify-content: space-between; in a flex container?
Consider a flex container with three items inside. What visual effect does justify-content: space-between; produce on these items?
AItems are grouped at the start of the container with no space between them.
BItems are centered with equal space around each item including container edges.
CItems are evenly spaced with equal space between them, but no space at the container edges.
DItems are evenly spaced with equal space around them including container edges.
Attempts:
2 left
๐Ÿ’ก Hint
Think about how space is distributed between items and container edges.
โ“ selector
intermediate
2:00remaining
Which CSS selector correctly targets only direct flex items inside a flex container?
Given a flex container with nested elements, which selector will select only the immediate flex items (children) but not deeper nested elements?
A.container > *
B.container *
C.container + *
D.container ~ *
Attempts:
2 left
๐Ÿ’ก Hint
Look for the selector that selects only direct children.
๐Ÿง  Conceptual
advanced
2:00remaining
What happens if you set flex-wrap: nowrap; on a flex container with many items?
If a flex container has many items that cannot fit in one line, what is the visual result when flex-wrap: nowrap; is applied?
AItems are hidden if they don't fit inside the container.
BItems wrap onto multiple lines to fit inside the container.
CItems shrink vertically to fit inside the container height.
DAll items stay on one line and may overflow the container horizontally.
Attempts:
2 left
๐Ÿ’ก Hint
Consider what nowrap means for line breaking in flexbox.
โ“ accessibility
advanced
2:00remaining
How can you improve keyboard navigation for a flex container used as a toolbar?
You have a flex container acting as a toolbar with buttons. What is the best way to ensure keyboard users can navigate the buttons in order?
AUse <code>span</code> elements styled as buttons with click handlers.
BUse semantic <code>button</code> elements and ensure the flex container has <code>role="toolbar"</code>.
CUse <code>div</code> elements with <code>tabindex="0"</code> and no ARIA roles.
DDisable keyboard focus on buttons to prevent confusion.
Attempts:
2 left
๐Ÿ’ก Hint
Think about semantic HTML and ARIA roles for toolbars.
๐Ÿ“ Syntax
expert
3:00remaining
What is the computed width of each flex item with this CSS?
Given this CSS for a flex container and its items:
.container { display: flex; width: 600px; } .item { flex: 1 1 200px; }

There are 4 items inside. What is the width of each item in pixels?
A150px each, because 600px divided equally among 4 items.
B200px each, because the flex-basis is 200px and items don't shrink.
C300px each, because items grow to fill container width.
D100px each, because items shrink below flex-basis.
Attempts:
2 left
๐Ÿ’ก Hint
Remember flex shorthand: flex-grow flex-shrink flex-basis. Items start at 200px but can shrink or grow.