【问题标题】:Adsense ads sometimes not centered and/or appearing in weird placesAdsense 广告有时不居中和/或出现在奇怪的地方
【发布时间】:2020-09-04 10:01:04
【问题描述】:

这似乎是一个相对简单的问题,但我找不到任何有效的答案。经常(但并非总是),当 Google 向我的网页投放广告时,它们会出现偏离中心或完全在父 div 之外。我知道这与广告在 div 内的绝对定位有关,我尝试过使用 CSS——包括在 style 属性下的 Google 广告代码中——但无济于事。

我没有使用自动广告,并将data-ad-format 字段更改为“水平”(第一张图片)和“矩形”(第二张图片)。我还将data-full-width-responsive 字段更改为“false”。

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- ad header -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-9877834918277834"
     data-ad-slot="1366524238"
     data-ad-format="auto"
     data-full-width-responsive="false"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>

包含广告的 div 的 CSS 如下:

.ad-slot {
  width: 100%;
  overflow: hidden; /* Otherwise be outside the div */
  text-align: center; /* Doesn't seem to do anything */
}

【问题讨论】:

    标签: css twitter-bootstrap adsense absolute


    【解决方案1】:

    原来是 iframe 样式问题。我正在修改一些 JS,结果意外地为页面上的所有 iframe(包括广告)设置了样式。

    【讨论】:

      猜你喜欢
      • 2016-09-19
      • 2016-09-05
      • 2015-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-14
      • 2020-11-28
      相关资源
      最近更新 更多