Skip to content

Instantly share code, notes, and snippets.

@jonsuh
Created December 3, 2012 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonsuh/4196593 to your computer and use it in GitHub Desktop.
Save jonsuh/4196593 to your computer and use it in GitHub Desktop.
Responsive Google AdSense Ads
.js-gads {
overflow: hidden;
}
<div class="js-gads">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-XXXXXXXXXXXXXXXX";
if (window.innerWidth <= 350) {
// Small ad
google_ad_slot = "XXXXXXXXXX";
google_ad_width = 320;
google_ad_height = 50;
} else if (window.innerWidth >= 750) {
// Large ad
google_ad_slot = "XXXXXXXXXX";
google_ad_width = 728;
google_ad_height = 90;
} else {
// Medium (fallback) ad
google_ad_slot = "XXXXXXXXXX";
google_ad_width = 468;
google_ad_height = 60;
}
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</div>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-XXXXXXXXXXXXXXXX";
if (window.innerWidth <= 350) {
// Small ad
google_ad_slot = "XXXXXXXXXX";
google_ad_width = 320;
google_ad_height = 50;
} else if (window.innerWidth >= 750) {
// Large ad
google_ad_slot = "XXXXXXXXXX";
google_ad_width = 728;
google_ad_height = 90;
} else {
// Medium (fallback) ad
google_ad_slot = "XXXXXXXXXX";
google_ad_width = 468;
google_ad_height = 60;
}
//--></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment