Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8576419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:55:11+00:00 2026-06-11T19:55:11+00:00

I have a div element, that has no defined width or height. It holds

  • 0

I have a div element, that has no defined width or height. It holds other elements, and molds on their size.
I need to get the final size of the div, without being able to check the sizes of the elements inside of it (dynamic elements).

I tried parsing all the properties of the object, but found nothing, all were “undefined”.

Any thoughts?

Many thanks

Later edit:

I have

<div id="xxx" style="position:relative;">  
    aaaa
</div>

I tried:

var a = mydiv.style.width;

But it did not work.

I also tried:

var getKeys = function (obj) {  
    var keys = [];

    for(var key in obj){  
        document.write(key+"="+obj.key+"<br>");  
    }  

    return keys;  
}  

getKeys(mydiv.style);  

To show all the properties, but none had any info.

The jQuery solution works perfectly, but getComputedStyle was what I was looking for, as I can’t use jquery here.

Sorry for the short information.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:55:13+00:00Added an answer on June 11, 2026 at 7:55 pm

    Based on no information whatsoever about what you were doing, I’d suggest that you should (if possible) use the window.getComputedStyle() approach, which finds the properties of an object as rendered by the browser:

    var elem = document.getElementById('elemId'),
        properties = window.getComputedStyle(elem, null),
        height = properties.height,
        width = properties.width;
    

    If you have jQuery available, then you can simply use the width() and height() (or outerWidth()/outerHeight()) methods:

    var height = $('#elem').height(),
        width = $('#elem').width();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have some JavaScript code that resizes <div/> elements (adjusts height/width/padding/margin etc.) based on
I have a div that will serve as container to other element, I have
I have two div elements that are twins (i.e. their dimensions and contents are
I have a div element with fixed height and width and overflow:hidden, and I
I have created a clickable div element that has a few links inside it.
I have a <div> element that has a click event attached to it using
Good Afternoon, I have a html aspx page that has many many div elements.
I have a div html element that has a click event set on it
I have a div element that has an id and this div contains a
I have a site I am designing that has some nested DIV elements that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.