Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stretching a div to fit absolutely positioned content

Tags:

css

Is there a way to do this with just css and no scripting? I have a div with a min-width, and inside of it is an absolutely positioned inner div with dynamically generated content of variable width. Sometimes the content extends beyond the containing div, but since its absolutely positioned it won't stretch the containing div. How do i get it to stretch the containing div? Thanks

like image 641
Joey Avatar asked Mar 02 '12 19:03

Joey


1 Answers

If your content element has position: absolute, it is not possible. However, sometimes you can avoid the absolute positioning and yet obtain the desired result by using a floating element instead. See this answer to a very similar question for an example.

like image 185
lex82 Avatar answered Oct 12 '22 23:10

lex82