Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto adjust the <div> height according to content in it?

Tags:

html

css

I have a <div> which needs to be auto adjusted according to the content in it. How can I do this? Right now my content is coming out of the <div>

The class I have used for the div is as follows

box-centerside  { background:url("../images/greybox-center-bg1.jpg") repeat-x scroll center top transparent; float:left; height:100px; width:260px; } 
like image 690
OM The Eternity Avatar asked May 27 '10 10:05

OM The Eternity


People also ask

How dynamically change the height of a div?

The content height of a div can dynamically set or change using height(), innerHeight(), and outerHeight() methods depending upon the user requirement.

How do I Auto adjust height in HTML?

If height: auto; the element will automatically adjust its height to allow its content to be displayed correctly. If height is set to a numeric value (like pixels, (r)em, percentages) then if the content does not fit within the specified height, it will overflow.

How do I Auto size a div?

The css rule: white-space: nowrap; will prevent your lines wrapping. Set a width of the error div to 100% and it will automatically fill the space available.


1 Answers

Just write "min-height: XXX;" And "overflow: hidden;" & you will be out of this problem Like this

min-height: 100px; overflow: hidden; 
like image 55
Adi Avatar answered Oct 18 '22 15:10

Adi