gpt4 book ai didi

html - 如何使响应式 AdSense 单元在浏览器调整大小时更改其大小

转载 作者:太空宇宙 更新时间:2023-11-04 14:02:12 25 4
gpt4 key购买 nike

我在高级模式下使用响应式 AdSense 单元。在我决定调整浏览器窗口的大小 之前,它运行良好。广告未按照媒体查询中指定的方式调整大小。

<style>
.myad { width: 320px; height: 50px; }
@media(min-width: 500px) { .myad { width: 468px; height: 60px; } }
@media(min-width: 800px) { .myad { width: 728px; height: 90px; } }
</style>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle myad"
style="display:inline-block"
data-ad-client="XXX"
data-ad-slot="XXX"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

CSS 是正确的。在 Firebug 中,我可以看到媒体规则被划掉并替换为如下内容:

element.style {
display: inline-block;
height: 90px;
width: 728px;
}

最佳答案

您的自适应 Google Ads 没有问题。

当您更改浏览器大小时,Google Ads 不会自动调整自己的大小。如果您刷新浏览器,那么 Google Adsense 将显示/转换大小与您浏览器/页面的当前大小相匹配的新广告。

我试图找到文档来验证我的陈述,但找不到任何相关内容。我的回答基于我使用自适应 Google 广告并对其进行测试的经验。


更新 30/05/2019 - 所有广告单元默认响应

Google 于 2019 年 5 月 30 日向 Adsense 发布商发送了一封电子邮件,告知即将对广告单元进行的改进。

电子邮件说:

We’re committed to continuously investing in the modernisation of our advertising products. As a result, there are some important changes we're making to some AdSense features that you have used or configured in the past. Your Ads tab will be updated in the coming weeks to reflect the following changes:

Ad sizes
We've made it easier to create and manage ad units. All ad units will be created Responsive by default to adjust to different screen sizes on mobile and desktop for increased performance and flexibility. If you do need further customisation, you’ll still be able to create custom sized ad units.

因此,在接下来的几周内,所有广告都将默认为自适应广告。以下是包含更多信息的两个 Google Adsense 帮助页面:

About responsive ad units

Create a responsive ad unit

关于html - 如何使响应式 AdSense 单元在浏览器调整大小时更改其大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26086799/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com