Technology News

First Look At The CSS object-view-box Property

Ahmad Shadeed — doing what he always does so well — provides an early look at the object-view-box property, something he describes as a native way to crop an image in the browser with CSS.

The use case? Well, Ahmad wastes no time showing how to use the property to accomplish what used to require either (1) a wrapping element with hidden overflow around an image that’s sized and positioned inside that element or (2) the background-image route.

But with object-view-box we can essentially draw the image boundaries as we can with an SVG’s viewbox. So, take a plain ol’ <img> and call on object-view-box to trim the edges using an inset function. I’ll simply drop Ahmad’s pen in here:

Only supported in Chrome Canary for now, I’m afraid. But it’s (currently) planned to release in Chrome 104. Elsewhere:

Direct Link →

Top Tips for the Beginner Graphic Designers
15 JavaScript Libraries for Creating Beautiful Charts

Related Articles

Behind the CSScenes, October 2022

Behind the CSScenes, October 2022
Well, hey, welcome back to Behind the CSScenes! These posts are like little check-ins we’re doing each month to give you a peek behind what we’re doing here at CSS-Tricks,…

6 Ways to Simplify HR Tasks Overnight

6-ways-to-simplify-hr-tasks-overnight
There are many wonderful things about running a business, but doing payroll and administering benefits usually don’t make the list. For many small businesses, HR is an afterthought, but that…

The 5 Best Design Handoff Tools in 2021

Exploring the Potential of the Metaverse: A New World Awaits
In this article, we’ll explore the current state of design handoff tools and the design process overall, and offer our pick of the five best design handoff tools on the…