Responsive adsense ad in the header
-
Hi Alex,
I have a created a new widget for the header section to display an adsense ad as per the steps you had mentioned in a previous thread.
What i wanted to know is how am i supposed to make that header ad responsive as it appears next to the site title on bigger screens but in smaller ones the ad goes underneath the site title.
Below is an excerpt i picked up from Google support where they describe how their ads change according to the size of its parent container.
Automatic sizing based on the space available. To make your code simpler and save you time and effort, our responsive ad code automatically adapts the ad unit size to your page layout. We calculate the required size dynamically based on the width of the ad unit’s parent container, then determine what’s the best standard height to go with that width.
For example, if you have a <div> with a width of 30% and you place our ad code within the <div>, then depending on the width of the user’s screen, we’ll automatically serve different ad sizes. If your page is viewed on a tablet with a width of 1024px, we’ll serve a 307×250 ad, and if it’s view on a 21″ desktop PC with a 1680px width, we’ll serve a 504×60 ad.
Now this is the code that i have added in the header.php section of the theme
<div style = "float: right;"><?php dynamic_sidebar('sidebar-header'); ?></div>
As per google’s description above the size of their ad changes according to the size of the parent div, so what size according to you should i give the div element in the code above.
Thanks,
Nev
- The topic ‘Responsive adsense ad in the header’ is closed to new replies.