Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a div grow with content?

Tags:

html

css

Pertaining to html, how do I make a div container grow with the content instead of manually defining a width and height.

<div id="container">   <div id="logo">     <img src="someimage.png"/>   </div> </div> 

No matter what the dimensions of logo are, container does not grow with it. :( How would I fix this, or can it be fixed?

like image 246
funk-shun Avatar asked Jan 11 '11 11:01

funk-shun


People also ask

How do I make divs expand upwards?

Use absolute positioning and instead of setting the offset with top use bottom . With this property you can ensure the position of the bottom edge of your div - any change in size will force the div to expand upwards.


1 Answers

If you don't define width and/or height, the div element grows along with its content. Unless his content is set to absolute! If the content is set to float, you have to set to the container

overflow:hidden 

in order to let it grow!

like image 152
stecb Avatar answered Sep 27 '22 23:09

stecb