, css "@media", -, , .
, , . , , , Google AdSense . , -, AdSense - , .
, ?
, , Google AdSense. , 2 AdSense - WordPress. . Google AdSense ( ) AdSense ( ).
, Google Adsense AdSense, , Adsense , , Google AdSense - .
, , javascript + css - , . , , css js.
:
, , (- ), / . - AdSense (320x50px) , , -, javascript / Google, , .
, , , . .
, CODEPEN, , AdSense . , iOS 7 iPhone 5.
, :
HTML:
AdSense <div> id="responsive-adsense " <div> id="adcontainer", , , , , .
<div class="adcontainer">
<div id="responsive-adsense">
</div>
</div>
JavaScript AdSense:
.
<div class="adcontainer">
<div id="responsive-adsense">
<script type="text/javascript">
google_ad_client = "ca-pub-928637890363315";
var containerWidth = document.getElementById( "responsive-adsense" ).offsetWidth;
if ( containerWidth >= 728 ) {
google_ad_slot = "2385224440";
google_ad_width = 728;
google_ad_height = 90;
}
else if ( containerWidth >= 468 ) {
google_ad_slot = "1350406442";
google_ad_width = 468;
google_ad_height = 60;
}
else if ( containerWidth >= 320 ) {
google_ad_client = "ca-pub-928637849363315";
google_ad_slot = "1350806442";
google_ad_width = 320;
google_ad_height = 50;
}
else if ( containerWidth >= 234 ) {
google_ad_slot = "2825039647";
google_ad_width = 234;
google_ad_height = 60;
}
</script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
</div>
</div>
javascript- 4 . Google AdSense, 3 , 3 . 1 , . - Google AdSense .
4 javascript :
- 234 x 60 - Half Banner
- 320 x 50 -
- 468 x 60 -
- 728 x 90 - Leaderboard
css -
AdSense css media, , , , . - , AdSense Mobile (320x50), ...
, display: none; - .
#responsive-adsense {
display: none;
}
#responsive-adsense{
display: none;
}
@media only screen and (max-width: 1023px) {
.adcontainer {
display: none;
}
#responsive-adsense{
display: none;
}
}
@media only screen and (max-width: 899px) {
.adcontainer {
width: 100%;
height: auto;
position: fixed;
bottom: 0px;
display: block;
background: #e74c3c;
color: #fff;
margin: 0 auto;
padding: 5px;
}
#responsive-adsense {
width: 728px !important;
display: block !important;
}
}
@media only screen and (max-width: 767px) {
.adcontainer {
width: 100%;
height: auto;
position: fixed;
bottom: 0px;
display: block;
background: #e74c3c;
color: #fff;
margin: 0 auto;
padding: 5px;
}
#responsive-adsense {
width: 728px !important;
display: block !important;
}
}
@media only screen and (max-width: 599px) {
.adcontainer {
width: 100%;
height: auto;
position: fixed;
bottom: 0px;
display: block;
background: #e74c3c;
color: #fff;
margin: 0 auto;
padding: 5px;
}
#responsive-adsense {
width: 468px !important;
display: block !important;
}
}
@media only screen and (max-width: 479px) {
.adcontainer {
width: 100%;
height: auto;
position: fixed;
bottom: 0px;
display: block;
background: #e74c3c;
color: #fff;
margin: 0 auto;
padding: 5px;
}
#responsive-adsense {
width: 320px !important;
display: block !important;
}
}
@media only screen and (max-width: 320px) {
.adcontainer {
width: auto !important;
padding: 0px !important;
height: 50px !important;
}
#responsive-adsense {
width: 320px !important;
display: block !important;
}
}
, : Google AdSense - , . https://support.google.com/adsense/answer/1354736?hl=en&topic=1271508
, Google , , , AdSense Google Adsense.
:
, AdSense -. , Google.
, :
http://www.labnol.org/internet/google-adsense-responsive-design/25252/
http://www.akshitsethi.me/google-adsense-responsive-ads-explained/
, . .