【问题标题】:Put an image over adsense在adsense上放一张图片
【发布时间】:2019-01-15 16:35:24
【问题描述】:

如何在 Google Adsense 上放置图片?我想跟踪用户点击,所以,当有人点击广告时,我想处理 onclick 方法。

.ad-alert {
    width: 728px;
    height: 400px;
    background: #cccccc;
    margin: auto;
    margin-top: 30px;
    z-index: 6000;
}

<div class="ad-alert" onclick="alert('test');">
    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <ins class="adsbygoogle"
        style="display:block; text-align:center; z-index: 4998"
        data-ad-layout="in-article"
        data-ad-format="fluid"
        data-ad-client="ca-pub-1543026956912231"
        data-ad-slot="207185479"></ins>
    <script>
        (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
</div>

但不起作用,.ad-alert 在广告后面,而不是我想要的前面。你能帮助我吗?谢谢!

【问题讨论】:

  • 你试过 z-index:6000 !important; ?
  • 是的! Google 广告始终显示在前面而不是后面。
  • 但您知道这违反了 adSense 政策吗?
  • 是的,我知道!但我得到报酬来创造这个。

标签: html css adsense


【解决方案1】:

您的.ad-alert 样式似乎缺少position: absolute,如果您想利用z-index 值,则需要此样式。

.ad-alert {
  position: absolute;

  width: 728px;
  height: 400px;
  background: #cccccc;
  margin: auto;
  margin-top: 30px;
  z-index: 6000;
}

您可以在这里了解更多关于absolute定位的信息:
https://developer.mozilla.org/en-US/docs/Web/CSS/position

【讨论】:

  • 您好,谢谢!但是广告仍然显示在 .ad-alert 前面,而不是后面! :(
  • 您可以尝试使用开发工具检查广告,看看它是否也在使用z-index。然后你可以试着把你的提高。
  • 我已经尝试过了,在开发工具控制台上更改了两个元素的z-index值,谷歌广告仍然显示在前面,我不知道为什么!
猜你喜欢
  • 2013-08-16
  • 2012-03-09
  • 1970-01-01
  • 2013-04-05
  • 1970-01-01
  • 2021-03-28
  • 2017-10-19
  • 2013-06-11
  • 1970-01-01
相关资源
最近更新 更多