From the course: CSS: Images
Unlock this course with a free trial
Join today to access over 22,600 courses taught by industry experts.
Position background image within a container
From the course: CSS: Images
Position background image within a container
- [Instructor] You can position the background image within the context of its containing element using the background-position property. Let me show you how that works. So I'll select the image here. And I'll add a new selector just to make it easier to see what's going on. And I'll say background-position. The background-position property can now take either one or two of the predefined keywords: bottom, center, left, right, and so on. Or you can put in numerical values for both the x-axis and the y-axis. So let's see what happens when I set background-position to bottom. Here, the bottom edge of the background image is aligned with the bottom edge of the containing box. Same thing happens with center. Now the image is centered in the box. Left aligns the left-hand edge with the left-hand edge, right, the right-hand edge with the right-hand edge, and top, which is the default, aligns the top edge of the image…
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
-
-
-
-
-