<aside>
  <p>🚨 Sorry, your browser doesn't support <code>:has()</code> - view this demo in <a href="https://caniuse.com/css-has" target="_blank">a supported browser</a>.</p>
</aside>

<ul>
  <li><span>Lorem</span></li>
  <li><span>Eaque</span></li>
  <li><span>Quasi</span></li>
  <li><span>Eligendi</span></li>
  <li><span>Delectus</span></li>
  <li><span>Illum</span></li>
  <li><span>Ratione</span></li>
</ul>
:root {
  --li-scale: 1.25;
  --li-scale-adj: 0.2;
  --li-pb: 0.25em;
}

li:hover {
  --li-pb: 0.75em;

  scale: var(--li-scale);
}

/* Select list item before the hovered one */
li:has(+ li:hover),
/* Select list item after the hovered one */
li:hover + li {
  --li-pb: 0.15em;
  --li-delay: 40ms;

  scale: calc(var(--li-scale) - var(--li-scale-adj));
  opacity: 0.85;
}

/* When a list item is being hovered,
select list items not hovered, or before/after hover */
ul:has(> :hover) li:not(:hover, :has(+ :hover), li:hover + *) {
  --list-pb: 0;
  --li-delay: 60ms;

  scale: calc(1 - var(--li-scale-adj));
  opacity: 0.75;
}

ul {
  list-style: none;
  padding: 0;
  display: grid;
  font-size: 1.15rem;
}

li {
  transition: all cubic-bezier(0.4, 0.8, 0.71, 1.03) 180ms;
  transition-delay: var(--li-delay, 0);
  padding-block: var(--li-pb);
  margin-inline: auto;
  width: 15ch;

  span {
    display: block;
    text-align: center;
    padding: 0.5em 1em;
    background-color: white;
    border-radius: 0.5em;
  }
}

/* :has() support alert */
aside {
  max-width: 30ch;
  padding: 1rem;
  background-color: palegoldenrod;
  border-radius: 0.5rem;
  margin-block-end: 1rem;
  line-height: 1.3;

  code {
    font-size: 1.25em;
    color: firebrick;
  }
}

@supports selector(:has(+ *)) {
  aside {
    display: none;
  }
}
View Compiled

External CSS

  1. https://codepen.io/5t3ph/pen/LYBGjpM/e1cf47eda72f658ccbf73f9056f6a53d.css

External JavaScript

This Pen doesn't use any external JavaScript resources.