<!doctype html>
<html lang="en">
<!--
position:absolute;
值 描述
absolute
生成绝对定位的元素,相对于 static 定位以外的第一个父元素进行定位。
元素的位置通过 "left", "top", "right" 以及 "bottom" 属性进行规定。
fixed
生成固定定位的元素,相对于浏览器窗口进行定位。
元素的位置通过 "left", "top", "right" 以及 "bottom" 属性进行规定。
relative
生成相对定位的元素,相对于其正常位置进行定位。
因此,"left:20" 会向元素的 LEFT 位置添加 20 像素。
static 默认值。没有定位,元素出现在正常的流中(忽略 top, bottom, left, right 或者 z-index 声明)。
sticky
粘性定位,该定位基于用户滚动的位置。
它的行为就像 position:relative; 而当页面滚动超出目标区域时,它的表现就像 position:fixed;,它 会固定在目标位置。
注意: Internet Explorer, Edge 15 及更早 IE 版本不支持 sticky 定位。 Safari 需要使用 -webkit- prefix (查看以下实例)。
inherit 规定应该从父元素继承 position 属性的值。
initial 设置该属性为默认值,详情查看 CSS initial 关键字。
-->
<head>
<meta charset="UTF-8">
<title>盒子模型</title>
<style>
/*菜单栏表格*/
.header{
height:50px;/*高度大小限制50像素*/
width:100%;/*屏幕的宽度*/
background:#FDBCFF;
position:absolute;/*位置固定*/
top:0;/*顶距离*/
}
/*表格里面的按钮*/
.header_Button{
position:absolute;/*位置固定*/
width:50%;/*控件大小按控件数量比例来算,如:2个按钮,屏幕长度100%,那每个按钮的长度就是100%/2=50%*/
height:50px;/*控件高度是你需要的高度*/
bottom:0px;/*设置一下,避免离开格子的位置*/
}
.main{
background:#E9FF4C;/*背景颜色*/
width:100%;/*屏幕宽度*/
position:absolute;/*位置固定*/
top:50px;/*离顶位置200像素*/
bottom:100px;/*离底距离200像素*/
height:auto;/*高度自动*/
}
.footer{
height:100px;/*高度限制100像素*/
width:100%;/*屏幕宽度*/
position:absolute;/*位置固定*/
bottom:0;/*离底位置0像素*/
background:#9E9E9E;/*背景*/
}
</style>
</head>
<body>
<div class="footer"></div>
<div class="main"><span>控制浏览器界面大小可以看到不同效果</span></div>
<table width="200" border="0" align="center" cellpadding="0" cellspacing="0" class="header">
<tbody>
<tr>
<td style="text-align:left"><button class="header_Button">首页</button></td>
<td style="text-align:left"><button class="header_Button">联系</button></td>
</tr>
</tbody>
</table>
</body>
</html>