Does anyone know if there is a way to show/hide a content block based on the dimensions of another element?

Basically, I have an advertising banner that automatically pulls in from an asset library and, when there are no paid adverts in this library, I'd like to pull in an internal/house banner.

My thought was to layer 2 blocks as so:

TOP BLOCK - show ad banner where available and collapse when nothing to display
(we already have this working well)

BOTTOM BLOCK - show house banner but only display if top block is empty

My thought was to put a display filter on the second block around something like "if height of top block is greater than zero then do not display" but not sure if this will work or how I'd go about writing the code.

Has anyone done anything like this before and know how it might work? I've only see the show/hide function working with buttons in the past.

Thanks for any help.