【发布时间】: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