.box {
  max-block-size: 10rem;
  overflow-y: auto;
  padding-inline: 1rem;
}

.head {
  position: sticky;
  top: 0;
  margin: 0;
  background-color: white;
  container-type: scroll-state;
}

@container scroll-state(stuck: top) {
  .head span {
    color: royalblue;
  }
}
