Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2003
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Code Check (center a page thats using (DIV"S)

    This Seems to work ok but is there a simple -er way of centering content of page that uses div's for precise placement?

    <BODY SCROLL="auto" onResize="DoReposition();" onLoad="DoReposition();" BGCOLOR="#FFFFFF" LINK="#808080" VLINK="#808080" TOPMARGIN=0 LEFTMARGIN=0>

    <SCRIPT LANGUAGE="JavaScript">
    <!--
    var agt=navigator.userAgent.toLowerCase();
    var is_major=parseInt(navigator.appVersion);
    var is_minor=parseFloat(navigator.appVersion);
    var is_nav=((agt.indexOf('mozilla')!=-1)&&(agt.indexOf('spoofer')==-1)&&(agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)&&(agt.indexOf('webtv')==-1));
    var is_ie=(agt.indexOf('msie')!=-1);
    if(is_ie){var agt_ie=agt.substring(agt.indexOf('msie')+5); is_major=parseInt(agt_ie); is_minor=parseFloat(agt_ie);}
    var is_dom2=(document.getElementById);
    // Browser detect
    if( is_minor < 5.0 )
    alert( "Your browser is very outdated. Please upgrade your browser to version 5 or later." );

    //-->
    </SCRIPT>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function HOffset()
    {
    var window_width = window.innerWidth ? window.innerWidth : (document.body.clientWidth ? document.body.clientWidth : 0);
    return Math.max( 0, Math.floor( (window_width - 760) / 2 ) - 0 ).toString();
    }

    function VOffset()
    {
    var window_height = window.innerHeight ? window.innerHeight : (document.body.clientHeight ? document.body.clientHeight : 0);
    return Math.max( 0, Math.floor( (window_height - 600) / 2 ) - 0 );
    }

    document.write( "<DIV ID='IDAlignPage' style='position:absolute; top:" + VOffset() + "px; left:" + HOffset() + "px;'>&nbsp;" );
    function DoReposition()
    {var o='IDAlignPage';
    if(is_dom2&&document.getElementById(o))
    {var e=document.getElementById(o);e.style.left=HOffset()+'px';e.style.top=VOffset()+'px';}
    else if(is_ie&&is_major>=4&&eval('document.all.'+o)){
    var e=eval('document.all.'+o);e.style.left=HOffset()+'px';e.style.top=VOffset()+'px';}
    else if(is_nav&&is_major>=4&&eval('document.'+o))
    {var c=eval('document.'+o);c.left=HOffset();c.top=VOffset();}}
    window.onresize=DoReposition;
    window.onload=DoReposition;
    //-->
    </SCRIPT>

    <DIV ID="idstart" editblock="top1"style="position:absolute; top:0px; left:0px; width:760px; height:600px;">start</DIV editblock="top1">

    <DIV ID="idElement8" style="position:absolute; top:0px; left:0px; width:758px; height:6px;"><IMG SRC="bar1.gif" NAME="idElement8Img" ID="idElement8Img" WIDTH=758 HEIGHT=6 BORDER=0></DIV>

    <DIV ID="idElement9" style="position:absolute; top:6px; left:487px; width:271px; height:43px;"><IMG SRC="col1.gif" NAME="idElement9Img" ID="idElement9Img" WIDTH=271 HEIGHT=43 BORDER=0></DIV>

    <DIV ID="idicon" style="position:absolute; top:6px; left:0px; width:57px; height:43px;"><IMG SRC="icon.gif" NAME="idiconImg" ID="idiconImg" WIDTH=57 HEIGHT=43 BORDER=0></DIV>

    Thank's for your time, -Maryjane.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes

    <div style="margin: 0 auto">
    <!-- content -->
    </div>
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •