有沒有解決方案可以爲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. 設置一個MEDIUM_RECTANGLE AdMob廣告的寬度,以適應屏幕寬度
- 5. ASP.NET廣告網站
- 6. CSS限制網站的寬度
- 7. jquery.AutoComplete.js自適應寬度
- 8. ASP.NET網站上的廣告
- 9. 針對低帶寬的測試網站?
- 10. DFP廣告管理系統自適應廣告
- 11. 調整站點寬度以適應iPad屏幕的寬度
- 12. 特色廣告php網站
- 13. 編碼自適應網站
- 14. 響應網站,CSS類型的寬度
- 15. 什麼應該是網站的寬度?
- 16. 廣告寬度大於調解中的屏幕寬度
- 17. 圖像在屏幕不會中央寬度上自適應網站
- 18. PayPal自適應付款 - 僅限邀請?
- 19. Bootstrap網站僅在移動設備上僅佔全身寬度
- 20. 調整大小DIV寬度自動適應一段的寬度
- 21. 全寬自適應網站正文圖片
- 22. 網站對齊寬度,會出錯
- 23. 固定寬度的網站
- 24. 轉換網站的寬度
- 25. iphone上的網站寬度
- 26. 根據視口寬度顯示廣告
- 27. android千禧廣告寬度問題
- 28. admob和android景觀寬度廣告
- 29. 將廣告寬度設置爲match_parent
- 30. 限制網站中視口的寬度和高度
如何設置googletag.pubads()。set(「document_language」,「en」); 爲安培廣告,任何想法? –
@SaurabhSashank請將此作爲一個單獨的問題。我將能夠提供幫助。 –
@Amrinder Dahul我們需要你的幫助。你能建議嗎? –