DIV+CSS 如何让左右两个DIV的高度一致?
我的DIV+CSS布局是#header,#pagebody,#footer,其中#pagebody分成#sidebar和#mainbody,#sidebar是导航栏,可以...
我的DIV+CSS布局是#header,#pagebody,#footer,其中#pagebody分成#sidebar和#mainbody,#sidebar是导航栏,可以展开、收缩的那种,#mainbody是主内容,因为各个内容不一样所以高度不固定,#sidebar有个底色,但是底色却不能显示,除了有内容的部分外其它区域是空白,是不是因为#sidebar的高度与#mainbody的高度不一致而导致的这种结果,请各位帮帮忙,谢谢!
展开
展开全部
最经典的两列自适应高度CSS代码,IE5、6、7,FF下测试通过。希望对你有用:
body{
padding: 0;
margin: 0;
color:#333/*#0d7206*/;
font-size: 14.7px;
font-family: Arial, Helvetica, sans-serif;
line-height: 140%;
text-align: center;
background:url(body_bg.jpg) #c8fdcc repeat-x top left;
}
#pagebody{
width: 760px;
margin:10px auto;
overflow: hidden;
}
#sidebar{
border-right:1px #009900 dotted;
width: 199px;
float: left;
background:url(l_bg_contbox.png) #FFF repeat-y left;
text-align: left;
}
#mainbody{
width: 560px;
float: left;
background:url(r_bg_contbox.png) /*#f6f6f6*/#fff repeat-y right;
text-align: left;
}
/* easy clearing */
#pagebody:after
{
content: '[DO NOT LEAVE IT IS NOT REAL]';
display: block;
height: 0;
clear: both;
visibility: hidden;
}
#pagebody
{
display: inline-block;
}
/*\*/
#pagebody
{
display: block;
}
/* end easy clearing */
/*\*/
#sidebar, #mainbody
{
padding-bottom: 32767px !important;
margin-bottom: -32767px !important;
}
@media all and (min-width: 0px) {
#sidebar, #mainbody
{
padding-bottom: 0 !important;
margin-bottom: 0 !important;
}
#sidebar:before, #mainbody:before
{
content: '[DO NOT LEAVE IT IS NOT REAL]';
display: block;
background: inherit;
padding-top: 32767px !important;
margin-bottom: -32767px !important;
height: 0;
}
}
/**/
body{
padding: 0;
margin: 0;
color:#333/*#0d7206*/;
font-size: 14.7px;
font-family: Arial, Helvetica, sans-serif;
line-height: 140%;
text-align: center;
background:url(body_bg.jpg) #c8fdcc repeat-x top left;
}
#pagebody{
width: 760px;
margin:10px auto;
overflow: hidden;
}
#sidebar{
border-right:1px #009900 dotted;
width: 199px;
float: left;
background:url(l_bg_contbox.png) #FFF repeat-y left;
text-align: left;
}
#mainbody{
width: 560px;
float: left;
background:url(r_bg_contbox.png) /*#f6f6f6*/#fff repeat-y right;
text-align: left;
}
/* easy clearing */
#pagebody:after
{
content: '[DO NOT LEAVE IT IS NOT REAL]';
display: block;
height: 0;
clear: both;
visibility: hidden;
}
#pagebody
{
display: inline-block;
}
/*\*/
#pagebody
{
display: block;
}
/* end easy clearing */
/*\*/
#sidebar, #mainbody
{
padding-bottom: 32767px !important;
margin-bottom: -32767px !important;
}
@media all and (min-width: 0px) {
#sidebar, #mainbody
{
padding-bottom: 0 !important;
margin-bottom: 0 !important;
}
#sidebar:before, #mainbody:before
{
content: '[DO NOT LEAVE IT IS NOT REAL]';
display: block;
background: inherit;
padding-top: 32767px !important;
margin-bottom: -32767px !important;
height: 0;
}
}
/**/
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把你整个布局代码贴出来看看```
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询