Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. Dynamically Positioning a layer

Dynamically Positioning a layer

Scheduled Pinned Locked Moved Web Development
questionc++javascriptphpsharepoint
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JKallen
    wrote on last edited by
    #1

    I am aC++ and php programmer/scriptor (sp?) but know little about javascript and the document object model. How do I dynamically find the the top and left values (IN PIXELS) of an object with respect to the top left of the browser window. I use tables to format pages so objects can have parents, grandparents, great-grandparents,..etc. The clientLeft and offsetLeft in conjunction with the offsetWidth dont give me the values I need to set the proper location. I need a way to find the position with respect to the top left corner of the client area of the IE Explorer browser window. I have searched the msdn and am not finding the answer. Thanks a million.

    T 1 Reply Last reply
    0
    • J JKallen

      I am aC++ and php programmer/scriptor (sp?) but know little about javascript and the document object model. How do I dynamically find the the top and left values (IN PIXELS) of an object with respect to the top left of the browser window. I use tables to format pages so objects can have parents, grandparents, great-grandparents,..etc. The clientLeft and offsetLeft in conjunction with the offsetWidth dont give me the values I need to set the proper location. I need a way to find the position with respect to the top left corner of the client area of the IE Explorer browser window. I have searched the msdn and am not finding the answer. Thanks a million.

      T Offline
      T Offline
      theJazzyBrain
      wrote on last edited by
      #2

      Dear CPian, in the HTML world, all tags have a STYLE called "position". The "position" style can have a few different values. The 3 most used that you should be aware of are: inline absolute relative The default one is INLINE which allows the HTML elements to be rendered as they are found within the HTML code. In other words they follow the flow of the code in respect of their parent element. The ABSOLUTE positioning will ignore the hierarchy for of the element(in the HTML code) to wich is applied and position the element to exact coordinates having as origin the most top and most left of the browser wndow. This is why you will notice that all asolutely positioned elements also have a LEFT and a TOP style, style attributes that take as values numbers in pixels, picas, ems and percentages and a few others that my mind is missing now. So an element coded as such: <DIV style="position:absolute; top:100px; left:100px;">I AM ABSOLUTELY POSITIONED</DIV> will have its origin(top left corner of the DIV) to the coordinate 100,100 discarding any parent elements. No matter where it is found within the code, its position wouldn't change. The RELATIVE positioning is the same with the ABSOLUTE with one main difference. It uses as an origin its parent elemets top most and left most position instead of the browser top most and left most position. Hope I helped. :P theJazzyBrain

      Excellence is not an act, but a habit!

      Aristotle

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups