0

I am using following HTML code to load ad from My server, I want to display it at center, I'm using some styles I got from Internet but nothing is working.

It is displayed at right corner , It must be responsive and at center

    <!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

Whats is wrong in this code, Thanks in advance

Straw Hat
  • 902
  • 14
  • 38
  • You are using an XHTML doctype, your inline CSS and JS will need to be in a [`CDATA` block](http://stackoverflow.com/questions/66837/when-is-a-cdata-section-necessary-within-a-script-tag). I would suggest moving to the HTML5 doctype ` ` instead since HTML5 is not XML it does not require a `CDATA` block. (And XHTML is essentially dead now). – Useless Code Mar 06 '14 at 08:33
  • @UselessCode I'll do that for sure, thanks – Straw Hat Mar 06 '14 at 09:03

1 Answers1

2

Just wrap the ad with a div, and make the div center.

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

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

Andrew
  • 5,290
  • 1
  • 19
  • 22