我正在尝试设计一个页面的风格,它非常接近,但我有点困惑。我的pageWrapper div被设置为占用100px的固定顶部49px的空间,目前是39px的固定底部。即使这样渲染效果非常接近预期的效果,但令人困惑的部分是我的页脚div只设置为24px的高度。我想知道额外15像素来自哪里。我怀疑它是我的researchTitle div类的产品,但这是一个包含div的子元素,不应以这种方式影响父元素。下面是我的格式化布局,而researchTitle设置为15px的高度使超过100%,造成术语类,它是100%去大CSS布局问题
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Question.aspx.cs" Inherits="Question" %>
<!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">
<head runat="server">
<title></title>
<style type="text/css">
#header
{
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 49px;
background: red;
overflow: hidden;
}
#pageWrapper
{
position: absolute;
height: auto;
top: 49px;
bottom: 39px;
left: 0px;
width: 100%;
}
#questionTop
{
overflow: auto;
position: relative;
left: 0;
width: 100%;
height: 40%;
background: blue;
overflow: auto;
}
#questionBottom
{
position: relative;
left: 0;
width: 100%;
height: 35%;
background: green;
overflow: auto;
}
#questionResearch
{
position: absolute;
left: 0;
width: 100%;
height: 25%;
}
#terms, #refs, #auth
{
position: absolute;
height: 100%;
}
#terms
{
left: 0;
width: 34%;
}
#refs
{
left: 34%;
width: 33%;
}
#auth
{
left: 67%;
width: 33%;
}
.researchTitle
{
position: relative;
top: 0;
height: 15px;
background: #999;
width: 100%;
}
.researchContent
{
position: relative;
overflow: auto;
background: #99C;
width: 100%;
height: 100%;
}
#footer
{
position: absolute;
left: 0;
width: 100%;
height: 24px;
bottom: 0;
background: red;
overflow: hidden;
}
</style>
</head>
<body>
<div id="header">
Header
</div>
<div id="pageWrapper">
<div id="questionTop">
<p>
First</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Last</p>
</div>
<div id="questionBottom">
<p>
First</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Last</p>
</div>
<div id="questionResearch">
<div id="terms">
<div class="researchTitle">
Terms</div>
<div class="researchContent">
<p>
First</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Last</p>
</div>
</div>
<div id="refs">
<div class="researchTitle">
Refs</div>
<div class="researchContent">
<p>
First</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Last</p>
</div>
</div>
<div id="auth">
<div class="researchTitle">
Authority</div>
<div class="researchContent">
<p>
First</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Item</p>
<p>
Last</p>
</div>
</div>
</div>
</div>
<div id="footer">
Footer
</div>
</body>
</html>
您可以设置演示吗? – Starx 2012-03-28 02:42:39
你很好奇为什么从底部开始的39px距离页脚的24px高度是15px? – mikevoermans 2012-03-28 02:43:40
额外的15px在哪里出现? – Starx 2012-03-28 02:49:03