Google AdSense Ads
At this point, I’m going to assume that you already have a Google AdSense account and are familiar with creating ads.
After you create an ad and you select Get code, you should see a dialog box with the script you would typically copy and paste to put on your page. It should look something like this:
For this example, create 3 different-sized ads: small for mobile devices, medium for tablets, large for desktop (I used a 320x50 for small, 468x60 for medium, and 728x90 for large).
Then with the example above, replace the google_ad_slot value, google_ad_width value, and google_ad_height value with the corresponding ad you created for that specific size (you’ll get those values by clicking Get code in Google AdSense within My Ads) in the proper section within the if/else statement.
If you’re comfortable enough and would like to adjust the small/large values, go ahead and do so.
In order to hide the overflow and prevent horizontal scrolling, you just need to wrap the script inside of a div and with one line of CSS, hide the overflow, which is as follows:
In closing, once you add the CSS to your stylesheet, you would achieve a responsive Google AdSense ad by the following:
Try the demo
I created a live demo example for you to try it along with a download link for you to try it on your own website.