<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/in-n-out-animation-using-sibling-index-master-dev-blog-gpabdpeo1" -->

---
title: In-N-Out Animation using sibling-index() – Master.dev Blog
description: A CSS-only technique for creating in-and-out animations using the `sibling-index()` function. When DOM elements are added or removed, their sibling indexes...
canonical: https://daily.dev/posts/in-n-out-animation-using-sibling-index-master-dev-blog-gpabdpeo1
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: In-N-Out Animation using sibling-index() – Master.dev Blog | daily.dev
og:description: A CSS-only technique for creating in-and-out animations using the `sibling-index()` function. When DOM elements are added or removed, their sibling indexes...
og:url: https://daily.dev/posts/in-n-out-animation-using-sibling-index-master-dev-blog-gpabdpeo1
og:image: https://api.daily.dev/og/posts/GpABDPeO1.png
og:image:alt: In-N-Out Animation using sibling-index() – Master.dev Blog
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# In-N-Out Animation using sibling-index() – Master.dev Blog

**[Frontend Masters](https://daily.dev/sources/frontendmasters)** · 7 min read · 9 upvotes · 0 comments

## Summary

A CSS-only technique for creating in-and-out animations using the `sibling-index()` function. When DOM elements are added or removed, their sibling indexes update, causing translated positions to recalculate and triggering smooth CSS transitions. Combined with `@starting-style` for entry animations, the entire effect requires fewer than 10 lines of CSS. The post covers the core technique, practical demos (avatar lists, circular layouts, responsive grids), and honest drawbacks: out-of-flow content, fixed item sizing requirements, and no native exit animation equivalent. Currently supported only in Chrome and Edge.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://master.dev/blog/in-n-out-animation-using-sibling-index>

## Similar posts on daily.dev

- [In-N-Out Animations: View Transitions \(Part 3/3\) – Master.dev Blog](https://daily.dev/posts/in-n-out-animations-view-transitions-part-3-3-master-dev-blog-pg7ta5epy) · Frontend Masters · 9 upvotes · 0 comments
- [In-N-Out Animations: Dialogs \(Part 1/3\) – Frontend Masters Blog](https://daily.dev/posts/in-n-out-animations-dialogs-part-1-3-frontend-masters-blog-yro2ic97o) · Frontend Masters · 4 upvotes · 0 comments
- [In-N-Out Animations: Popovers \(Part 2/3\) – Master.dev Blog](https://daily.dev/posts/in-n-out-animations-popovers-part-2-3-master-dev-blog-vgzaenwev) · Frontend Masters · 10 upvotes · 0 comments
- [Staggered Animation with CSS sibling-\* Functions – Frontend Masters Blog](https://daily.dev/posts/staggered-animation-with-css-sibling--functions-frontend-masters-blog-o9x9nobox) · Frontend Masters · 0 upvotes · 0 comments
- [How to create awesome staggered animations in CSS](https://daily.dev/posts/how-to-create-awesome-staggered-animations-in-css-k09m57ftt) · LogRocket · 52 upvotes · 2 comments

---

Tags: [#css](https://daily.dev/tags/css)

[View this post on daily.dev](https://daily.dev/posts/in-n-out-animation-using-sibling-index-master-dev-blog-gpabdpeo1)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"In-N-Out Animation using sibling-index() – Master.dev Blog","url":"https://daily.dev/posts/in-n-out-animation-using-sibling-index-master-dev-blog-gpabdpeo1","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/in-n-out-animation-using-sibling-index-master-dev-blog-gpabdpeo1"},"datePublished":"2026-07-13T17:38:37.269Z","dateModified":"2026-07-13T17:39:00.382Z","description":"A CSS-only technique for creating in-and-out animations using the `sibling-index()` function. When DOM elements are added or removed, their sibling indexes...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/821713b67091fa56ea4f43844aff8172?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/821713b67091fa56ea4f43844aff8172?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Frontend Masters","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Frontend Masters","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/d34dd87208f24090bfb0917307fcf89f","url":"https://daily.dev/sources/frontendmasters"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/in-n-out-animation-using-sibling-index-master-dev-blog-gpabdpeo1","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":9},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"css","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Frontend Masters","item":"https://daily.dev/sources/frontendmasters"},{"@type":"ListItem","position":3,"name":"In-N-Out Animation using sibling-index() – Master.dev Blog"}]}
```

