The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › CSS › Extending an absolutely positioned div to content height
Is there a way in CSS to allow an absolutely positioned element to extend to it’s content’s height?
Because you allow the content to overflow, but the element stays the same height.
Take a look at this and lemme know if I’m just missing something:
[Codepen test case](http://cdpn.io/uBHad “Codepen link”)
To start…why are you using absolute positioning?
You’ve told the parent to be a certain height and it’s obeying. The absolutely positioned element is just doing what you have told it to.
What you seem to be trying to do is force the parent element to respect the height of the child and absolute positioning can’t do that.
You can do something like this: http://codepen.io/Merri/pen/bzCBD
Practical uses for this are quite limited though. If you can define a better use case then answers may improve.
Do you mean a centered dialog?
With some jQuery: http://codepen.io/senff/pen/xCBsn