Skip to content
Justice Tech School

Responsive Backgrounds and Images

Use max-width: 100%, object-fit and image-set() for flexible images. Load different backgrounds in media queries to save data on phones.

Example
<style>
img { max-width: 100%; height: auto } .bg { height: 60px; background: #0f766e center / cover }
</style>
<div class="bg"></div>

Exercise

Never overflow the parent.

max-width: %;

Quiz Test

Which keeps image proportions?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.