javascript - 中心图像和来自 Javascript 的内容

标签 javascript html css

我正在使用以下 HTML 代码从我的服务器加载广告, 我想在中心显示它,我正在使用从 Internet 获得的一些样式,但没有任何效果。

显示在右上角,必须响应式且居中

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <style type="text/css">
    html, body {
    width:100%;
    height: 100%;
    margin: 0px;
    padding: 0px;

// some code I got to center that content
    max-width: 100%;
    max-height: 100%;
    margin: auto;
    overflow: auto;
    position: fixed;
    margin-left: auto; margin-right: auto;

    }


    </style>
    </head>
    <body>

<!-- this script loads the ad -->
    <script type='text/javascript'>
    var age = "23";
    var gender="male";
    //var location1="testifying";

       var m3_u = (location.protocol=='https:'?'https://openxtest.wfihotspotnet.in/delivery/ajs.php':'http://openxtest.wfihotspotnet.in/delivery/ajs.php');
       var m3_r = Math.floor(Math.random()*99999999999);
       if (!document.MAX_used) document.MAX_used = ',';
       document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
       document.write ("?zoneid=6");
       document.write ("&amp;TarGender=");
       document.write ('&amp;cb=' + m3_r);
       if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
       document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
       document.write ("&amp;loc=" + escape(window.location));
       if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
       if (document.context) document.write ("&context=" + escape(document.context));
       if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
       document.write ("'><\/scr"+"ipt>");
    </script>

    </body>
    </html>

JS Fiddle Demo

这段代码有什么问题,在此先感谢

最佳答案

只需用 div 包裹广告,并使 div 居中。

.myad{
    width: 310px;
    margin:0 auto;
}

http://jsfiddle.net/EzVEd/1/

关于javascript - 中心图像和来自 Javascript 的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22218751/

相关文章:

python - 如何解决 selenium webdriver 中的斜线问题?

javascript - 出现在父元素顶部的子元素的框阴影

html - 使顶部 div 与其下方的 div 一样宽

html - 在 HTML 表格单元格中调整 SVG 的大小

html - 将导航菜单居中

javascript - HTML5/Javascript SSE限制调用次数

javascript - Jquery nestedSortable 所有 parent 首先都是空的

javascript - 华丽的弹出窗口 : Get current element in callback

javascript - php javascript 将脚本放在文件中

html - 在网格列内,无论图像位置如何,相对于图像的中心标题