Considerations when defining your DIV
This script will work on both DIVs with an explicit CSS "height" attributed defined, and those without. For example:
Code:
<!--DIV with height defined -->
<div id="dog" style="width: 300px; height: 110px;"></div>
Code:
<!--DIV without height defined-->
<div id="cat" style="width: 300px;"></div>
The advantage of a DIV with a height attribute explicitly defined is that the user can expand/contract the DIV almost immediately, instead of after the document has fully loaded (when the script can dynamically get its height). Of course, in real life, you often cannot set the DIV's height in advanced for various reasons, and this script will still work in these cases.
Another thing to take note is if you wish to add padding/margins to the DIV- you'll need to do it inside another DIV contained within it instead, for example:
Code:
<div id="cat" style="width: 300px;">
<div style="padding: 0 5px">
Some content
</div>
</div>
In other words, the "padding: 0 5px" declaration shouldn't be added inside the starting DIV itself, but within it. The reason for this limitation is that padding and margins will throw off certain calculations within the script.
Bookmarks