Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic height of div with css

Tags:

html

css

My HTML:

<!-- Content -->
    <div class="content">
        <!-- Content left -->
        <div class="content-left"></div>
        <!-- Content center -->
        <div class="content-center">

        </div>
        <!-- Content right -->
        <div class="content-right"></div>
    </div>

My CSS:

.content
{
 background-color: black;
 height: auto;
 margin: 80px auto 0px auto;
 min-height: 100px;
 padding: 10px 10px;
 width: 1200px;
}

.content-center
{
 -khtml-box-shadow: 0px -3px 5px rgba(0,0,2,2);
 -moz-box-shadow: 0px -3px 5px rgba(0,0,2,2);
 -webkit-box-shadow: 0px -3px 5px rgba(0,0,2,2);
 background-color: #ffffff;    
 border-left: 1px solid;
 border-right: 1px solid;
 border-color: #999999;
 box-shadow: 0px -3px 5px rgba(0,0,2,2);
 height : 900px;
 float: left;
 width : 800px;
}

.content-left
{
 background-color: #fff;
 float: left;
 height: 300px;
 width: 190px;
}

.content-right
{
 background-color: #fff;
 float: left;
 height: 300px;
 width: 190px;
}

My problem is DIV with class "content" don't have same height with other element as child of this tag. I want div with class "content" have dynamic height according to "content-center", "content-left" or "content-right". I have use min-height and height : auto in class "content" but it still not correct.

like image 265
sirait Avatar asked Feb 19 '13 07:02

sirait


2 Answers

Add overflow:auto to .content

.content{
  width: 1200px;
  min-height: 100px;
  height: auto;
  margin: 80px auto 0px auto;
  background-color: black;
  padding: 10px 10px; 
  overflow:auto
}

DEMO

like image 153
Sowmya Avatar answered Oct 14 '22 19:10

Sowmya


Try this:

* {
    margin: 0;
    padding: 0;
}

html, body {
    height:100%;
}

.content {
    width: 1200px;
    min-height: 100px;
    height: auto;
    margin: 80px auto 0px auto;
    background-color: black;
    padding: 10px 10px;
    display:table;
    overflow:hidden;
    height:100%;
}

Demo Here

like image 2
palaѕн Avatar answered Oct 14 '22 17:10

palaѕн