How can I hide another DIV on collapsed Ad Manager ads?

独自空忆成欢 提交于 2020-07-22 08:30:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!