问题:左右布局时,右边中的 子box 的顶部 跟 左边的 最底部对齐

Mybeautiful 2010-08-02 02:41:51
如题:
左右布局时,右边中的 子box顶部 跟 左边的 最底部对。



附上 简化后的布局代码 (展示 看到我的布局情况,并不能重现我的问题)



<html >
<head>
<title>test page</title>
<style type="text/css">

body {
margin: 0;
padding: 0;
font: 70% 'Lucida Grande', Verdana, Helvetica, sans-serif;
text-align: center;

border:solid 2px;
}

#wrapper { /* width: 750px; */
width: 97%;
margin: 0 auto;
background-color: #F7F1EB;
padding: 0 10px 10px 10px;
text-align: left;
}

#header {
margin: 10px 15px 15px 15px;
height: 100px;

border: solid 1px;
}

#left {
width: 250px;
margin: 0px 0 0 15px;
padding: 10px 10px;

border: solid 1px;
float: left;

height:300px;

border: solid 1px;
}

#right {
margin: 0px 15px 0 295px;
padding: 10px 10px;
border: solid 1px;

height:300px;
width:700px;
}


#left_c{
margin: 0px 15px 0 0px;
padding: 10px 10px;
border: solid 1px;

height:280px;
width:220px;
}


#right_c{
margin: 0px 15px 0 0px;
padding: 10px 10px;
border: solid 1px;

height:280px;
width:680px;
}




.clearBoth{
float:clear;
}



</style>
</head>
<body>
<div id="wrapper">

<div id="header">
A
</div>

<div class="clearBoth"></div>
<div id="left" >
<div id="left_c">
B
</div>

</div>

<div id="right">
<div id="right_c">
C
</div>
</div>

</div>
</body>
</html>



Box C的顶部 可能跟left的最底部对其...


希望我把问题说清楚了,请各位予以解惑..



...全文
90 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Winter_Sco 2010-08-03
  • 打赏
  • 举报
回复
你的整体页面的宽度若是用百分比的话就都用百分比,左右的宽度你写死了,在不同分辨率下就容易出错,左边把右边挤下去了就,margin: 0px 15px 0 295px;这么大的居左值不出错才怪。你可以参考下下面的代码

<html >
<head>
<title>test page</title>
<style type="text/css">

body {
margin: 0;
padding: 0;
font: 70% 'Lucida Grande', Verdana, Helvetica, sans-serif;
text-align: center;

border:solid 2px;
}

#wrapper { /* width: 750px; */
width: 97%;
height:100%;
margin: 0 auto;
background-color: #F7F1EB;
padding: 0 10px 10px 10px;
text-align: left;
}

#header {
margin: 10px 0 15px 0;
height: 100px;
border: solid 1px;
}

#left {
width:25%;

padding: 10px 10px;

border: solid 1px;
float: left;

height:300px;

border: solid 1px;
}
#left_c{
padding: 10px 10px;
border: solid 1px;
height:280px;

}
#right {
float:right;
padding: 10px 10px;
border: solid 1px;
height:300px;
width:68%;
}


#right_c{
padding: 10px 10px;
border: solid 1px;

height:280px;

}




.clearBoth{
float:clear;
}



</style>
</head>
<body>
<div id="wrapper">

<div id="header">
A
</div>

<div class="clearBoth"></div>
<div id="left" >
<div id="left_c">
B
</div>

</div>

<div id="right">
<div id="right_c">
C
</div>
</div>

</div>
</body>
</html>

Mybeautiful 2010-08-02
  • 打赏
  • 举报
回复
请看图片,问题在图中用红色字体描述,
Mybeautiful 2010-08-02
  • 打赏
  • 举报
回复
谢谢 Wings_JK的回复。

right_c 是在 right 中吧 ?

假设 left 的高度是 100px, 现在问题就是: right_c 的的顶端从 100px开始 (上面留了100px的空白!)
Wings_JK 2010-08-02
  • 打赏
  • 举报
回复
说实话。。没怎么看懂LZ的意思,给个效果图吧

61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧