Adsense广告有时不会居中和/或出现在怪异的地方

问题描述

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

我没有使用自动广告,而是将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 */
}

enter image description here

enter image description here

解决方法

原来这是一个iframe样式问题。我当时在用一些JS乱搞,无意间结束了页面上所有iframe(包括广告)的样式。