css - Adsense 广告有时不居中和/或出现在奇怪的地方
问题描述
这似乎是一个相对简单的问题,但我无法找到任何有效的答案。经常(但并非总是),当 Google 向我的网页投放广告时,它们会出现偏离中心或完全在父 div 之外。我知道这与广告在 div 中的绝对定位有关,我尝试过使用 CSS(包括在style
属性下的 Google 广告代码中),但无济于事。
我没有使用自动广告,并将data-ad-format
字段更改为“水平”(第一张图片)和“矩形”(第二张图片)。我还将该data-full-width-responsive
字段更改为“假”。
<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 */
}
解决方案
原来这是一个 iframe 样式问题。我正在使用一些 JS 并意外地最终设计了页面上的所有 iframe(包括广告)。
推荐阅读
- python - 为什么 return list_name.append(something) 没有返回?
- python - python3中的子进程
- python - 将熊猫数据框字符串拆分为单独的行
- java - 尝试将机器人合并到有关 jakarta 的应用程序错误中
- forms - Puppeteer 无头模式无法正常运行
- sql-server - 查询时态表并合并行
- php - 更新 php mysql 图像字段丢失
- javascript - 我想在不使用 + 或 * 符号的情况下获得三个数字的总和
- sqlite - Lightroom SQLite 数据库二进制 XMP 格式
- cassandra - Cassandra 在计算列时是否考虑毫秒?