如何在全屏html5游戏中集广告? 我的游戏经过精心设计,可以让您在玩游戏时全屏显示。 我希望我的广告始终位于中心,无论是否在平板电脑/ PC /等上播放。
那我该如何集中我的广告?
这是我的广告代码
<div id="goog" style="position:absolute; left:0; top:10;">
<script type="text/javascript">
<!--
google_ad_client = "ca-pub-xxxxxxxxx";
google_ad_slot = "xxxxxxxx";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</div>
我试过这个document.getElementById("goog").align = 'center';
,但它不起作用。
答案 0 :(得分:1)
你可以试试这个
更改<div id="goog" style="position:absolute; left:0; top:10;">
到
<div id="goog" style="position:absolute; left:50%; top:50%;margin-top:-125px;margin-left:-175px;width:350px;height:250px;">
OR
<style>
#goog { position:absolute; left:50%; top:50%;margin-top:-125px;margin-left:-175px;width:350px;height:250px; }
</style>
然后是html
<div id="goog">