问题
I use Google Ad Manager and have placed some ads on my website. With the following code I make sure that empty ads are collapsed:
.setCollapseEmptyDiv(true, true)
This works very well. But I have placed the note " Ad" next to each advertisement (because legally required). The problem: If no ads are delivered and the ads are collapsed, the word " Ad" floats around on the page. This is located in its own DIV (because I want to place and display it exactly via CSS).
How can I hide another DIV if a specific Google advertisement is collapsed?
回答1:
In this particular case, I would rather use css pseudo element than create an other div to play with. Let's suppose your html anchor in which Ad Manager is generating the ad call is the following :
<div id="ad-banner"></div>
With CSS and a pseudo element (some details here) you could add the "Advertising" word before the div :
<style type="text/css">
#ad-banner::before {
content: 'Advertising';
display:block;
width:100%;
height:auto;
font-size:12px;
text-align:center;
}
</style>
As it belongs to the selected div, if the div #ad-banner is styled "display:none", the pseudo element is hidden too.
Hope this helps.
来源:https://stackoverflow.com/questions/57796067/how-can-i-hide-another-div-on-collapsed-ad-manager-ads