早教吧 育儿知识 作业答案 考试题库 百科 知识分享

求css左侧宽度固定右侧宽度自适应的办法请调整浏览器窗口html,body{margin:0;padding:0;border:none;font-size:12px;color:#000000;line-height:180%;background-color:#f2f6fb;overflow:hidden;height:100%;}#content{position:relative

题目详情
求css左侧宽度固定右侧宽度自适应的办法
请调整浏览器窗口
html,body
{
margin:0; padding:0;border:none; font-size:12px; color:#000000; line-height:180%;
background-color:#f2f6fb;overflow:hidden;height:100%;
}
#content
{
position:relative;
width:100%;
height:98%;
left:50%;
margin-left:-50%;
}
#left{
float:left;
width:252px;
height:100%;
border:1px solid #000;
}
#right{
width:100%;
margin-left:-253px;
height:100%;
float:right;
border:1px solid #000;
}


左侧



#left是固定252px并且border 1px 关键是右侧的#right让他如何自适应宽度 border也是1px
我这样写右边跑下面去了
▼优质解答
答案和解析





#left{
float:left;
width:252px;
text-align:center;
border:1px solid #000;
}
#right{
margin-left:252px;
text-align:center;
border:1px solid #f00
}

无标题文档



固定252px




其实楼主你的代码里只要把right的width:100%;和float:去掉就可以了.你100%的话他就是外层的宽度~当然会掉下去~而flaot的话~如果没有设定宽度他是根据自身的内容决定宽度.无法自适应.