Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript jQuery
Hi,
 
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
}
else
{
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 6:46am
Edited 4-Apr-13 7:35am
(no name)499.6K
v2
Comments
Moykn at 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
0 Peter Leow 255
1 Mika Wendelius 240
2 CHill60 195
3 TheRealSteveJudge 180
4 Zoltán Zörgő 178
0 Sergey Alexandrovich Kryukov 8,658
1 OriginalGriff 6,591
2 Peter Leow 3,982
3 Zoltán Zörgő 3,604
4 Richard MacCutchan 2,510


Advertise | Privacy | Mobile
Web04 | 2.8.150123.1 | Last Updated 4 Apr 2013
Copyright © CodeProject, 1999-2015
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