日期:2014-05-16  浏览次数:20742 次

浮动对齐问题
头部和底部固定,中间是上浮复盖头部一点。但底部没办法接着中间下面显示,头总和底宽是自适应的,中间是1000px。。。。求大虾门正解方法

<style type="text/css">
<!--
#top{
height:300px; 
background-color:#0033CC;
}
#box{
position: absolute;
top:240px;
left:50%;
width:1000px;
margin-left:-500px;
background-color:#FF6666;
height:auto;
}
#bottom{
height:200px;
background-color:#009933;
width:auto;
}
-->
</style>
<div id="top">头部</div>
<div id="box">
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
</div>
<div id="bottom">底部</div>


------解决方案--------------------

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
<!--
#top{
width:100%;
height:300px; 
background-color:#0033CC;
}
#content{width:100%;height:1000px;background-color:#ccc;position:relative;}
#box{
position:absolute;
    top:240px;
    left:50%;
background-color:#FF6666;
    height:auto;
width:1000px;
margin-left:-500px;
float:left;
}

#bottom{
height:200px;
background-color:#009933;
width:100%;
}
-->
</style>
</head>

<body>

<div id="top">头部</div>
<div id="content">
   <div id="box">
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>