Getting the CSS Height of a Div
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Getting the CSS Height of a Div

  1. #1
    Join Date
    Sep 2007
    Posts
    9

    Getting the CSS Height of a Div

    Hi
    I am facing a problem of getting the CSS height and width values of a DIV element for nearly two days now. I have tried all kinds of methods but I couldn't get it work.

    I have a DIV which is defined by a CSS class in an external CSS file. The dimensions are 300x300. The thing is, I need to get the values inside the code.

    How do I do that? Thanks!

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,869

    Re: Getting the CSS Height of a Div

    Use the offsetHeight property.

    You really should try a Google search next time. It would have taken you about 15 seconds to find the answer.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Sep 2007
    Posts
    9

    Re: Getting the CSS Height of a Div

    Well, just for your information, I've been working on this problem for two days before I posted it here. That's first.

    Second, the offsetHeight property calculates the height of the element after the rendering, i.e. adding the spacing values (padding, borders etc.). So this is not good for me.

    But apparently all I had to do was change something in my code. I used getComputedStyle. Google that up.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center