Give #box a 16/9 aspect ratio.
Acceptance criteria
- 1.Give #box a 16/9 aspect ratio.
CSS Tutorial · CSS Layout
These 10 tasks go with the Aspect Ratio & Object Fit chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “Reserve stable media space with aspect-ratio and control how images and video fit and align inside their boxes. You will reserve stable media space and compare cover, contain, fill, scale-down, and object-position for images and video.” .
1.Set a widescreen ratioexercise · easy · 10 min
Give #box a 16/9 aspect ratio.
Passes when: Give #box a 16/9 aspect ratio.
2.Make it squareexercise · easy · 10 min · practice plan
Give #box a 1/1 aspect ratio.
Passes when: Give #box a 1/1 aspect ratio.
3.Cover the boxexercise · easy · 10 min · practice plan
Set object-fit to cover on #box.
Passes when: Set object-fit to cover on #box.
4.Contain the contentexercise · easy · 10 min · practice plan
Set object-fit to contain.
Passes when: Set object-fit to contain.
5.Combine ratio and fitexercise · medium · 10 min · practice plan
A 4/3 box whose content covers it.
Passes when: A 4/3 box whose content covers it.
6.Fix the misspelled propertybug fix · easy · 8 min
The property is aspect-ratio.
Passes when: The property is aspect-ratio.
7.Fix the ratio written with a colonbug fix · easy · 8 min · practice plan
A CSS ratio uses a slash, not a colon.
Passes when: A CSS ratio uses a slash, not a colon.
8.Fix the wrong fit valuebug fix · easy · 8 min · practice plan
"fill-cover" is not a valid object-fit value.
Passes when: "fill-cover" is not a valid object-fit value.
9.Fix cover used where contain was meantbug fix · easy · 8 min · practice plan
The content should fit entirely inside the box.
Passes when: The content should fit entirely inside the box.
10.Fix the inverted ratiobug fix · easy · 8 min · practice plan
A 4/3 box is wider than it is tall.
Passes when: A 4/3 box is wider than it is tall.
Between them these tasks cover aspect-ratio, object-fit and object-position.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.