html div容器不会被内部的内容占据高度

时间:2013-01-08 15:08:47

标签: html containers

为什么<div id = "container">的身高为433px?我创建了这个页面http://www.elektroninescigaretes.ym.lt/,当我检测到一个元素时,它显示我只有433px并且我想在页脚上保留所有权利保留(c)的东西,所以我需要div来拥有所有页面的高度不仅仅是上半部分。

//index file
<?php include ("template/header.php"); ?>
<div id = "home_content"></div>
<?php include ("template/footer.php"); ?>


//header file

<!DOCTYPE html>
<html>
<head>
<link rel = "stylesheet" href = "media/styles/style.css" media = "screen">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>el Cigarai</title>
</head>
<body class = "<?php 
$remove = array(".php", "/");
$url = $_SERVER['SCRIPT_NAME'];
$current_file = str_replace($remove, "", $url);
 $current_page = explode('_', $current_file);
 echo $current_page[0];
?>">

<div id = "container">

//footer file

</div>
</body>
</html>

  /style file

#container{
position: relative;
margin: 0 auto;
width: 960px;
height: 100%;
}
#home_content{
position: absolute;
top: 294px;
right: 60px;
width: 960px;
height: 750px;
background-image: url('../images/woman.jpg');
background-repeat: no-repeat;
overflow: hidden;
}

2 个答案:

答案 0 :(得分:0)

把它放在你的风格中:

html body{height: 100%;}

答案 1 :(得分:0)

您的高度设置为100%,这意味着如果您的内容增长大于视口(或父容器)所代表的100%,它将不会增长。尝试使用

min-height:100%