Reputation:
I have a page in which expanding content flows out of the holding div, the relevant CSS is below as well. Simply removing the height:510px
line will allow the div
to expand as needed. However, new users who have no content will not have any height and the page will look unblanced. How do I set a minimum height?
.Bb1
{
width:680px;
height:510px;
background-color:#ffffff;
float:left;
border-right:3px solid #edefed;
border-radius: 10px;
}
Upvotes: 50
Views: 105059
Reputation: 11
Do this:
.minHeight {
min-height: 100px;
height: auto;
border: 1px solid red;
/* IMPORTANT -- always set 'height: auto;' immediately after the min-height attribute */
}
<div class="minHeight">
this div has a min-height attribute
</div>
Upvotes: 1
Reputation: 6187
Here is d way through which you can set min height of a div
<div id="bb1" style="min-height:200px;>
.....
</div>
or apply
#bb1{
min-height:200px;
}
if you have used class
like
<div class="bb1">
in div then use
.bb1{
min-height:200px;
}
Upvotes: 3
Reputation: 2512
.comments { min-height:650px;height:auto; }
<div class="comments">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam cursus. Morbi ut mi.</div>
Upvotes: 2
Reputation: 2091
Incase you want to set a minimum/maximum height and minimum/maximum width to a div
, CSS allows the specific feature.
To set the minimum width of the div
or any other class/id/element, use;
min-width: 150px;
To set the minimum height of the div
or any other class/id/element, use;
min-height: 300px;
Similarly for setting maximum width and height of a div
or any other class/id/element, use;
max-width: 600px;
max-height: 600px;
Important:
For your div
to expand freely in height and width after data is available for users; you will have to set the width/height to auto
immediately after you have set the min-width
or min-height
.
min-width: 300px;
width: auto;
min-height: 100px;
height: auto;
Upvotes: 25
Reputation: 4089
CSS allows a "min-height" property. This can be used to set the minimum height of the div you're talking about.
#div-id { min-height: 100px; }
Upvotes: 54