-
DIV resizing issue
I would like my div container's height to automatically resize with the content that is added dynamically or dragged & dropped into it. I couldnt figure out the proper CSS without using fixed height and a scrollbar that I don't want. I tried using javascript to resize the container when new content is added to it but the scrollHeight always gets larger & larger even as I remove content. Here is my JS function, is there a better property I could use to determine:
1. If the content area of the div container is larger than the client window then resize the container to be the size of the content area else resize the container to be the size of the client window
function resize(){
var htmlheight = document.body.parentNode.scrollHeight;
var windowheight = document.body.parentNode.clientHeight;
var containerDiv = document.getElementById(containerId);
if ( htmlheight < windowheight ) {
containerDiv.style.height = windowheight + "px";
}
else {
containerDiv.style.height = htmlheight + "px";
}
}
-
-
If you have a free standing division with a width, but no height specified, its height will automatically adjust to whatever content is placed inside of it, up to 100% of the height of any container it may be inside of.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks