Docs
Components
Intersect

Intersect

An element that can be used to detect when an element enters or leaves the viewport.

This will be dificult to implement with just HTML and CSS, but it is probably possible - most likely with position sticky and CSS conditionals.