From the course: CSS: Images
Unlock this course with a free trial
Join today to access over 22,600 courses taught by industry experts.
Fitting background images to any container
From the course: CSS: Images
Fitting background images to any container
- [Instructor] Background images have their own set of CSS properties. You can use to control sizing, position, and many other features. If you go to the MDN Web Docs, you'll get a full breakdown of all of these properties and what they do. In this movie and the next one, I'll cover some of the basics of this and the features you're most likely to use. In this example, I've added a background image to the container you see here. I've used the background-image property to do so to specify this is just the background image. And when you add a background image, it is automatically added in its full size. So what you're seeing here is actually just a top left corner of the whole background image. It is scaled to its full size, and then it's cropped by the container. If I want to resize this background image to make it fit within the container, I used a background-size property. Background-size has two familiar settings…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Modern image markup5m 55s
-
(Locked)
Getting rid of the space underneath an image4m 3s
-
(Locked)
Fitting an image inside any container5m 45s
-
(Locked)
Create a square (or other proportion) image5m 48s
-
(Locked)
Position an image inside a container3m 4s
-
(Locked)
Use CSS to crop an image3m 18s
-
(Locked)
Fitting an image inside a grid cell3m 8s
-
(Locked)
Fitting an image inside flexbox4m 38s
-
(Locked)
Fitting background images to any container2m 33s
-
(Locked)
Position background image within a container4m 55s
-
-
-
-
-