Jump to content

Div expanded by content / get height with javascript


astralaaron

Recommended Posts

In my CSS file, my div has a min-height of 600px. The problem I am having is that one of my javascripts needs to know the height of this div, and sometimes, depending on the content, the div will expand beyond 600px. When I try to get the height with javascript, it still says 600px even if it has expanded. Any advice is appreciated!

Link to comment
Share on other sites

Your original post says that you wanted the size of the div. The offsetHeight property tells you the vertical size of the div even if it has expanded to contain more content.

 

Since the div expands with the content, its height is also the same as the height of the content that's within it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...