Responsive List of Avatars Using Modern CSS (Part 1) | CSS-Tricks
Briefly

Responsive List of Avatars Using Modern CSS (Part 1) | CSS-Tricks
"You are for sure wondering what the novelty we are bringing here is, right? It has been done countless times. You are right. The main idea is not complex, but the new thing is the responsive part. We will see how to dynamically adjust the overlap between the images so they can fit inside their container. And we will make some cool animations for it along the way!"
"Declaring flexbox on the container is all we need to line the images up in a single row: .container { display: flex; } We can make the images circles with border-radius and squish them close together with a little negative margin: .container img { border-radius: 50%; margin-right: -20px; } .container img:last-child { margin: 0; } Nothing fancy so far. I am using an arbitrary value for the margin to create an overlap:"
Start with a set of image elements inside a parent container. Apply display:flex to line images in a single row. Apply border-radius to make circular images and use negative margin-right to create overlap. Apply a radial-gradient mask to cut images and create transparent gaps between overlaps so one image does not obscure the next. Use sibling-index() and sibling-count() to compute dynamic offsets and adjust overlap responsively to fit the container. Add hover interactions and animations to enhance behavior. Current browser support is strongest in Chrome and Edge; Firefox and WebKit support are in progress.
Read at CSS-Tricks
Unable to calculate read time
[
|
]