SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Absolute positioning & retrieving height

    Hello all,

    I'm trying to get the height of an element that contains content which is absolutely positioned. As far as I can tell, because the absolute positioned content is taken out of the page flow, you cannot retrieve the 'visible' height (ie height as seen onscreen) of the element with properties like clientHeight / offsetHeight.

    Is there any way to access the visible height of an element like this?

    Thanks a lot!

  2. #2
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do you mean by visible height? If the absolutely positioned child element(s) is removed from the flow of the document, then the height will be affected, there's not a lot you can do about that.

    Why don't you just add the clientHeight of the absolutely positioned element and its parent element together?

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Buddy,

    By visible height, I mean what is shown on screen as opposed to the height of the element as reported by offsetHeight (which is 0 if all its content is absolutely positioned).

    Yeah I was thinking of adding up all the heights, but as the browser 'sees' abs positioned content - ie it creates a scrollbar if it goes off page - I wondered if its height was accessible somehow.

  4. #4
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    An absolutely positioned element will return its offsetHeight and offsetWidth and its clientHeight and clientWidth in IE, firefox and Opera.


Bookmarks

Posting Permissions

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