2016-04-21 50 views

回答

1

这对我很好。它采取了最大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> 
+0

如何设置googletag.pubads()。set(“document_language”,“en”); 为安培广告,任何想法? –

+0

@SaurabhSashank请将此作为一个单独的问题。我将能够提供帮助。 –

+0

@Amrinder Dahul我们需要你的帮助。你能建议吗? –

1

基于此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> 

希望这有助于!

+1

不,这不是工作。对于AMP必须输入大小等: <安培广告宽度= 300 HEIGHT = 200 类型= “的AdSense” 数据的广告客户端= “XXX” 数据的广告时隙= “XXX”> 你不能用css修改这个。 – Lovntola

0

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>

+0

请编辑该答案,格式不好。编辑答案时,请查看编辑提示。现在你有文本与代码混合。最后问问自己,这个答案是否给已经存在的其他答案带来了新的东西。 – Nic3500