javascript - How to make an element's height increase with every child added to it -
i have <div> has children appended script. these children elements automatically appended php script , positioned using position:absolute. tried give parent <div> style min-height:400px allowing elements appended <div> increase parent's height. problem height not increase when this. know can fix this?
edit: not able use position:relative positioning elements. there solutions allow position:absolute.
yes can use position absolute (yeee♥!)
by doing:
$(this).height( this.scrollheight ); or pure js:
this.style.height = this.scrollheight ; and adding element's css:
overflow:hidden; overflow-y:auto; edit:
the demo tested fine in ie10, firefox, chrome, safari, , opera.
the key point here setting overflow value x or y axis (whichever dimensions need size of) auto, rather default value of visible. scrollwidth or scrollheight property can used on html dom object full size of element, including absolutely-positioned descendants.
odd seems, entirely consistent fact setting overflow:hidden container clips absolutely-positioned descendants. apparently, elements position:absolute aren't quite "out of flow" we've been told :)
Comments
Post a Comment