Html 渲染元素乱序
我在页面布局方面遇到问题。我必须混合使用表格和 div。页脚和包含表格的 div 会出现此问题。页脚显示在该 div 上方,但在 html 中,它是“main_container”内的最后一个元素。
<style>
#sidebar {
position: relative;
display: block;
float: left;
width: 30%;
}
#TblContain {
position: relative;
display: block;
float: right;
width: 70%;
}
#footer {
position: relative;
width: 100%;
display: block;
}
</style>
<div id="main_container">
<div id="head">
</div>
<div id="nav_bar">
</div>
<div id="content">
<div id="sidebar">
</div>
<div id="TblContain">
<table></table>
</div><!--endTblContain-->
</div><!--endContent-->
<div id="footer">
</div><!--endFooter-->
</div><!--endMainContain-->
I'm having trouble with page layout. I'm having to use a mix of tables and divs. The problem occurs with the footer and the div containing the table. The footer is being displayed above that div but in the html it is my last element inside the "main_container".
<style>
#sidebar {
position: relative;
display: block;
float: left;
width: 30%;
}
#TblContain {
position: relative;
display: block;
float: right;
width: 70%;
}
#footer {
position: relative;
width: 100%;
display: block;
}
</style>
<div id="main_container">
<div id="head">
</div>
<div id="nav_bar">
</div>
<div id="content">
<div id="sidebar">
</div>
<div id="TblContain">
<table></table>
</div><!--endTblContain-->
</div><!--endContent-->
<div id="footer">
</div><!--endFooter-->
</div><!--endMainContain-->
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果清除:向左;不起作用,尝试添加clear:both;到 css 中的页脚。
if clear:left; doesn't work, try adding clear:both; to the footer in the css.
这比尝试浮动 div 容易得多。此外,它还允许您调整页面大小,并允许您的个人内容区域滚动。
http://jsbin.com/ugoli3/2/edit
This is much easier, than trying to float the divs. In addition it will allow your page to be re-sizable and your individual content area scrollable.
http://jsbin.com/ugoli3/2/edit
尝试添加:
到页脚。
Try adding:
to the footer.