Anchor positioning and similar modern CSS features handle a lot of relative-motion work, but sometimes the simplest route to a small animation is the older one: transform the parent, and let the children follow. Changing an element's intrinsic sizing and orientation propagates to everything inside it, which makes a single parent animation stand in for several child ones.

Circles Moving Through One Another

A <main> element holding four child .circle elements is enough markup:

<main>
  <div class="circle"></div>
  <div class="circle"></div>
  <div class="circle"></div>
  <div class="circle"></div>
</main>

Rotating each circle separately means defining and setting several animations. Rotating the shared parent needs only one, so the circles are first contained and absolutely positioned inside <main>:

main {
  contain: layout;
}

.circle {
  position: absolute;

  &:nth-of-type(1){
    background-color: rgb(0, 76, 255);
  }
  &:nth-of-type(2){
    background-color: rgb(255, 60, 0);
    right: 0;
  }
  &:nth-of-type(3){
    background-color: rgb(0, 128, 111);
    bottom: 0;
  }
  &:nth-of-type(4){
    background-color: rgb(255, 238, 0);
    right: 0;
    bottom: 0;
  }
}

A dedicated .animate class carries the parent rotation:

/* Applied on <main> (the parent element) */
.animate {
  width: 0;
  transform: rotate(90deg);
  transition: width 1s, transform 1.3s;
}

JavaScript applies that class to <main> when the button is clicked:

const MAIN = document.querySelector("main");
function play() {
  MAIN.className = "";
  MAIN.offsetWidth;
  MAIN.className = "animate";
}

Visually it reads as four animated circles; mechanically it is one animated parent. Each .circle is absolutely pinned to a corner of <main>. When .animate is added, the parent's width shrinks and it rotates 90deg — the shrink draws every circle toward the parent's center while the rotation swaps their positions, passing them through each other. Per-element animations can be layered on top for extra variation.

Parent Distortion, Child Compensation

A pair of .square children can cross during the animation the same way:

/* Applied on <main> (the parent element) */
.animate {
  transform:  skewY(30deg) rotateY(180deg);
  transition: 1s transform .2s;
  
  .square {
    transform: skewY(30deg); 
    transition: inherit;
  }
}

Here <main> skews 30deg and flips along the Y-axis, while both children answer with the same skew so the distortion cancels. The squares trade places while separating. To keep the separation but drop the flip, the parent takes a 30deg skew and the children a -30deg one:

/* Applied on <main> (the parent element) */
.animate {
  transform:  skewY(30deg);
  transition: 1s transform .2s;
  
  .square {
    transform: skewY(-30deg); 
    transition: inherit;
  }
}

Putting skew() on a parent lets children be rearranged in ways plain rectangular geometry will not allow. Whatever the parent does can be complemented, countered or cancelled at the child level, depending on the desired effect.

Scaling combines just as readily, with the parent's skewY() negated by the children's scale() at a different value to offset it:

/* Applied on <main> (the parent element) */
.animate {
  transform: rotate(-180deg) scale(.5) skewY(45deg) ;
  transition: .6s .2s; 
  transition-property: transform, border-radius;
  
  .squares {
    transform: skewY(-45deg) scaleX(1.5); 
    border-radius: 10px;
    transition: inherit;
  }
}

In that example the parent runs rotate(-180deg), shrinks with scale(.5) and skews with skewY(45deg). Each child negates the skew using skewY(-45deg) and stretches the square into a horizontal bar with scaleX(1.5).

Triggering Without JavaScript

These combinations can be driven by a <details> element instead of a scripted interaction: the animation fires when it enters the [open] state after a <summary> click. Each <summary> holds an .icon child that runs its own animation as the element toggles open and closed. Clicking a <details> toggles it and shows the animation in action.

The takeaway is that transforming a parent intrinsically affects its children's size, position and orientation — so complex per-child animations are often unnecessary. Leverage what the parent can do, then adjust at the child level as needed. That is easy to forget, and it makes for leaner, more efficient animation code.