日期:2014-05-18  浏览次数:20449 次

请教一CSS布局问题
<style type="text/css">
#DIV1 {
height: 100%;
width: 100%;
background-color: #900;
}
#divLeft {
float: left;
height: 100%;
width: 200px;
background-color: #FF0;
}
#divAll {
background-color: #F0F;
float: left;
height: auto;
width: auto;
}
</style>
<div id="DIV1">
  <div id="divLeft">此处显示 id "divLeft" 的内容</div>
  <div id="divAll">此处显示 id "divAll" 的内容</div>
此处显示id "DIV1" 的内容</div>

DIV1里有两个DIV,
divLeft的宽度必须为200px,余下的空间让divAll填满,应该怎么做?

------解决方案--------------------
#divAll {
background-color: #F0F;
float: left;
height: auto;
width: auto;
}

中的
float: left;
删除就可以的
<style type="text/css">
#DIV1 {
height: 100%;
width: 100%;
background-color: #900;
}
#divLeft {
float: left;
height: 100%;
width: 200px;
background-color: #FF0;
}
#divAll {
background-color: #F0F;
height: auto;
width: auto;
}
</style>
<div id="DIV1">
<div id="divAll">
<div id="divLeft">此处显示 id "divLeft" 的内容</div>
<div>此处显示 id "divAll" 的内容</div>
 </div>
<div style="height:0;clear:both"></div>
此处显示id "DIV1" 的内容</div>
------解决方案--------------------
探讨
#divAll {
background-color: #F0F;
float: left;
height: auto;
width: auto;
}

中的
float: left;
删除就可以的
<style type="text/css">
#DIV1 {
height: 100%;
width: 100%;
background-color: #900;
}
……

------解决方案--------------------
高度100%,依赖于父容器。如果父容器没设,肯定不行。