From the course: CSS: Images
Unlock this course with a free trial
Join today to access over 22,600 courses taught by industry experts.
Use CSS to crop an image
- [Illustrator] In the previous movie, I said you could use object fit and object position to crop an image to display the way you want. However, there's a limit to this. You'll remember object fit will display the image so that it fills out the shortest value either horizontal or vertical. In this case because the image is wider than the displayed box, that means we are seeing the full height of the image right now and I can't change that using object fit or object position. If I try to move the image vertically using object position nothing will happen. What if I want to zoom in on this image and do an actual crop, like what you would do in Photoshop or another photo editing tool. In that case, I need to turn to CSS Transforms. CSS Transforms allow us to rotate, scale, skew or translate, meaning move along the X or Y-axis, any element and it does all of this in the coordinate space of CSS. The cool thing about…
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
-
-
-
-
-