有沒有解決方案可以爲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我們需要你的幫助。你能建議嗎? –