Googleアドセンス
Googleアドセンスの広告ユニットには、レスポンシブ広告ユニットもありますが、それを使わないやり方です。規約に違反しないようにコードを編集します。
例)
画面幅が960pxより大きい場合は728×90を表示し、小さい場合は320×50を表示します。
アドセンスコード内を編集します。 width = document.documentElement.clientWidth; を追加し、 data-adを各々入力します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<script type="text/javascript"><!-- google_ad_client = "ca-pub-4658976513256489"; width = document.documentElement.clientWidth; google_ad_slot = "1657984652"; google_ad_width = 320; google_ad_height = 50; if ( width >= 960) { google_ad_slot = "6498579821"; google_ad_width = 728; google_ad_height = 90; } //--> </script> <script type="text/javascript" src="https://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> |
レスポンシブのチェックサイト
Responsive Design Testing
https://mattkersley.com/responsive/
画面幅、240、320、480、768、1024pxでの見え方がチェックできる便利なサイトです。
これの良いところは1ページ内に5つの幅すべてのプレビューが表示されるところです。使い方は、確認したいサイトのアドレスを入力するだけです。
コメントを残す