[英]Problem with extending my div to the bottom of the page
当内容不足时,在将div扩展到页面底部时,我需要帮助,当我将100%的高度添加到内容和容器中时,没有任何变化,当我将其添加到主体时,一切都变得混乱了。 我试图提供尽可能多的信息,因此在下面提供了CSS和HTML。
(所有这些,对于这个问题,很多可能是不必要的,抱歉)
body {
background-color: #111014;
background-image: url("images/bg.png");
background-repeat: repeat-x;
color: #dad8df;
font-family: tahoma;
overflow-y: scroll;
}
#container {
height: 100%;
width: 1000px;
margin-left: auto;
margin-right: auto;
}
img{
border-style: none;
}
#banner {
margin-top: 45px;
margin-bottom: 38px;
height: 68px;
width: 1000px;
background-image: url("images/bannerbg.png");
}
#navigation {
height: 36px;
width: 1000px;
margin-left: 49px;
}
#content {
background-image: url("images/contentbg.png");
background-repeat: repeat-y;
height: 100%;
width: 850px;
padding-left:80px;
padding-bottom: 20px;
margin-bottom: -8px;
padding-right: 50px;
overflow: hidden;
}
#title {
height: 90px;
width: 542px;
padding-left: 60px;
padding-top: 36px;
background-image: url("images/titlebg.png");
background-repeat:no-repeat;
font-family: tahoma;
font-size: 2.5em;
color: #dad8df;
margin-left: -80px;
}
#slideshow {
height: 285px;
width: 840px;
margin-left: auto;
margin-right: auto;
background-color: #2e2c35;
float: left;
margin-bottom: 20px;
}
#slideleft {
height: 38px;
width: 23px;
background-image: url("images/slideleft.png");
float: left;
margin-left: -60px;
margin-top: 104px;
}
#slideright {
height: 38px;
width: 23px;
background-image: url("images/slideright.png");
float: right;
margin-right: -50px;
margin-top: 104px;
}
#emailform {
color: #dad8df;
font-family: tahoma;
overflow: hidden;
}
.inputs {
float: right;
width: 200px;
font: .9em tahoma;
}
#largemessage {
float: right;
clear: both;
width: 700px;
height: 150px;
resize: none;
font: .9em tahoma;
}
#submit {
margin-top: 20px;
clear: both;
float: right;
}
hr {
border-width: 3px 0 0 0;
border-style: dotted;
}
.contacterror {
margin-right: 180px;
height: 20px;
width: 300px;
color: red;
float: right;
padding-left: 20px;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>About :: Lesley Robb Fine Art and Design</title>
<link rel="icon" type="image/png" href="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="design.css" type="text/css"/>
<script src="" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="banner">
</div>
<div id="navigation">
<a href="index.php"><img src="images/nav_home.png" alt="Home" /></a><a href="portfolio.php"><img src="images/nav_portfolio.png" alt="Portfolio" /></a><a href="about.php"><img src="images/nav_about.png" alt="About" /></a><a href="contact.php"><img src="images/nav_contact.png" alt="Contact" /></a>
</div>
<div id="content">
<div id="title">
About
</div>
You can edit this section after you Log In to the Control Panel. :)</div>
</div>
</body>
</html>
预先感谢您的宝贵时间,Callum
通常,如果您添加
body, html{
height:100%;
}
container div
将继承它。
尝试使用一种称为Faux Columns的技术。
尝试将#container div的高度设置为auto。
#container {
height:auto;
那应该做!
正如文档所说:
相对于生成的盒子的包含块的高度计算百分比。 如果未明确指定包含块的高度(即,它取决于内容的高度),并且此元素不是绝对定位的,则该值将计算为“自动”
http://www.w3.org/TR/CSS2/visudet.html#the-height-property
如果添加html,body { height:100%; }
html,body { height:100%; }
搞砸了,这肯定是因为浏览器为这些元素设置了默认的边距/填充。
对于您的问题,更简单的解决方案是将#container
min-height设置为视口高度,并将其设置为可伪造#content
到达底部的背景。 像纳撒尼尔(Nathaniel)所说的人造柱 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.