8

我的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>

我的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;
}

我的问题是带有“内容”类的 DIV 与其他元素的高度不同,因为该标签的子元素。我希望具有“内容”类的 div 根据“内容中心”、“内容左”或“内容右”具有动态高度。我在“内容”类中使用了 min-height 和 height : auto 但它仍然不正确。

4

2 回答 2

23

添加overflow:auto.content

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

演示

于 2013-02-19T07:22:23.010 回答
2

试试这个:

* {
    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%;
}

在这里演示

于 2013-02-19T07:40:51.910 回答