Chameleonic Header

Sebastiano Guerriero has published a demo of a fixed-position header that changes its colors to suit whatever background sits behind it. As the header crosses from one differently-colored region into another, its colors flip to match the new backdrop.

The trick relies on having several copies of the header, one per section, stacked in the same place. Those copies are hidden from screenreaders, and each section carries a clip-path around it; when the next section arrives, its copy is revealed.

A bonafide CSS trick if I’ve ever seen one.

It also raises the question of whether there is a simpler route — some magical value of mix-blend-mode that would do the whole job. Chris Coyier’s attempt got close enough to give him hope.