Click here to Skip to main content
13,147,591 members (30,278 online)
Rate this:
Please Sign up or sign in to vote.
See more:

I'm using scrollHeight property to find the height of a div element. It is calculating the height value a little bit additional resulting in extra blank space.

I'm using this to toggle between expand contents and contract them such that
if(element.height == element.scrollHeight)
element contracts on button click
element expands on button click

The contents of the div are a paragraph and table with four to five rows. The toggle option is working fine. But the scrollheight is calculating excessive height resulting in irregular additional spaces to each div for which i had used this concept.

Please suggest me some alternative or a solution to this issue.

Thanks in advance
Posted 4-Apr-13 5:46am
Updated 4-Apr-13 6:35am
Moykn 4-Apr-13 12:46pm
does your css contains any padding or margin for the div element?
paragraphs have a default top and bottom margin.
If you are using chrome, use inspect element, maybe it could help you to se what element is causing the extra space.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170915.1 | Last Updated 4 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100