This content originally appeared on CSS-Tricks and was authored by Chris Coyier
I hope people think of SVG as a vector format that is good for drawing things. There is plenty more to know, but here’s one more: SVG is good for composition. You draw things at very specific coordinates in SVG and, while they can scale, they tend to stay put. And while SVG is a vector format, you can place raster images onto it. That’s my favorite part of Cassie’s “Swipey image grids” post. The swipey part is cool, but the composition is even cooler.
<svg viewBox="0 0 100 100">
<rect x="30" y="0" width="70" height="50" fill="blue"/>
<rect x="60" y="60" width="40" height="40" fill="green"/>
<rect x="0" y="30" width="50" height="70" fill="pink"/>
<image x="30" y="0" width="70" height="50" href="https://place-puppy.com/300x300"/>
<image x="60" y="60" width="40" height="40" href="https://place-puppy.com/700x300"/>
<image x="0" y="30" width="50" height="70" href="https://place-puppy.com/800x500"/>
</svg>
You’ll need to check this out in Chrome, Edge or Firefox:
Don’t miss Cassie’s interactive examples explaining preserveAspectRatio
. That’s a thing I normally think of on the <svg>
itself, but is used to great effect on the <image>
elements themselves here. It’s like a more powerful object-fit
and object-position
.
Direct Link to Article — Permalink
The post Swipey Image Grids appeared first on CSS-Tricks.
You can support CSS-Tricks by being an MVP Supporter.
This content originally appeared on CSS-Tricks and was authored by Chris Coyier
Chris Coyier | Sciencx (2021-05-03T14:35:07+00:00) Swipey Image Grids. Retrieved from https://www.scien.cx/2021/05/03/swipey-image-grids/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.