有没有解决方案可以为AMP添加自适应AdSense? 像100px高度(用于计算布局)和100%宽度。针对AMP网站的自适应广告(仅限宽度)
回答
这对我很好。它采取了最大EQ高100像素和宽度:100%
<amp-ad
width="320" height="100"
media="(max-height: 100px)"
layout="responsive"
type="adsense"
class="adsbygoogle ads_mystyle"
data-ad-client="xxx"
data-ad-slot="xxx">
</amp-ad>
基于此blog,因为AMP是异步的,Adsense的AMP HTML可以通过CSS进行响应。当您要使用异步Adcodes时,您需要将此脚本包含在HTML的头部分中。
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
下面是示例代码:
<style>
.headerad { width: 100%; height: 100px; }
@media(min-width: 320px) { .headerad { width: 320px; height: 100px; } }
</style>
<amp-ad class="headerad"
type="adsense"
data-ad-client="ca-pub-XXXX"
data-ad-slot="YYYY">
</amp-ad>
如果你想Customize Google Adsense Async Responsive ADS Size,你需要首先生成一个AdSense adunit
。
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- ADUnit -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-xxxxxx"
data-ad-slot="yyyyyy"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
头广告:
<style>
.headerad { width: 320px; height: 100px; }
@media(min-width: 468px) { .headerad { width: 468px; height: 60px; } }
@media(min-width: 728px) { .headerad { width: 728px; height: 90px; } }
</style>
<!-- Header Ad -->
<ins class="adsbygoogle headerad"
style="display:inline-block"
data-ad-client="ca-pub-xxxx"
data-ad-slot="yyyy"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
希望这有助于!
不,这不是工作。对于AMP必须输入大小等: <安培广告宽度= 300 HEIGHT = 200 类型= “的AdSense” 数据的广告客户端= “XXX” 数据的广告时隙= “XXX”> 你不能用css修改这个。 – Lovntola
hi;
AMP Project forbidden style and max-height
there are 2 range responsive amp ads code
1. for header or page in or post in
width is not required.
width, flexible responsive 'the width of the area'.
height, max 400 flexible.
(problem sidebar wrapper - problem footer problems mobile wiev)
<pre><code>
amp-ad
layout="fixed-height"
height="400"
type="adsense"
data-ad-format='auto'
data-ad-client="ca-pub-1234567898xx"
data-ad-slot="9876xx">
/amp-ad
</pre></code>
2. with width and height.
for everywhere (but sometimes not responsive)
<pre><code>
amp-ad
layout="responsive"
height="336"
width="280"
type="adsense"
data-ad-format='auto'
data-ad-client="ca-pub-12345678xx"
data-ad-slot="9876xx">
/amp-ad
</pre></code>
请编辑该答案,格式不好。编辑答案时,请查看编辑提示。现在你有文本与代码混合。最后问问自己,这个答案是否给已经存在的其他答案带来了新的东西。 – Nic3500
- 1. 的AdSense链接广告(或广告链接)与自适应网站
- 2. 使用@media更改宽度(最小宽度:XXXXpx)自适应广告
- 3. 制作网站横幅广告幻灯片的宽度为
- 4. ASP.NET广告网站
- 5. jquery.AutoComplete.js自适应宽度
- 6. ASP.NET网站上的广告
- 7. 调整站点宽度以适应iPad屏幕的宽度
- 8. 特色广告php网站
- 9. 什么应该是网站的宽度?
- 10. 响应网站,CSS类型的宽度
- 11. 广告宽度大于调解中的屏幕宽度
- 12. 图像在屏幕不会中央宽度上自适应网站
- 13. PayPal自适应付款 - 仅限邀请?
- 14. android千禧广告宽度问题
- 15. 将广告宽度设置为match_parent
- 16. admob和android景观宽度广告
- 17. 全宽度背景响应网站
- 18. HTML css表格宽度自适应
- 19. 两个div自适应宽度
- 20. Firebase广告,仅测试广告
- 21. PHP网站和AdSense的广告轮播
- 22. 网站上的背景广告
- 23. ASP.NET网站的广告管理
- 24. 如何识别网站上的广告
- 25. DBMS设计这样的广告网站
- 26. 使用playframework的自适应网站
- 27. php自动网站地图一个免费的分类广告网站
- 28. 为您的网站创建广告系统(我自己的AdSense)
- 29. 网站栏目宽度
- 30. 可变宽度网站
如何设置googletag.pubads()。set(“document_language”,“en”); 为安培广告,任何想法? –
@SaurabhSashank请将此作为一个单独的问题。我将能够提供帮助。 –
@Amrinder Dahul我们需要你的帮助。你能建议吗? –