CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2003
    Posts
    1

    Layer Centering Question

    I want to have a layer set to be centered on a page based on browser size,. i.e. the layer will be centered within the browser regardless of whether it is being viewed on a laptop or on a 21 inch monitor. Any thoughts on a simple way to do this?

  2. #2
    Join Date
    Feb 2003
    Location
    Oakland, CA
    Posts
    29
    Try this in IE. not sure about the other browsers, but you can check out the API for them on their websites.

    var theDiv = document.getElementById("myDiv");
    theDiv.style.position = "absolute";
    var px = theDiv.offsetWidth/2;
    theDiv.style.left = (window.document.body.offsetWidth / 2) - px;
    Nate Grover
    http://www.nategrover.com

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured