<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>全屏布局使用position</title>
<style type="text/css">
html,
body,
.parent {
margin:
0;
height:
100 %;
overflow: hidden;
}
body {
color: white;
}
.top {
position: absolute;
top:
0;
left:
0;
right:
0;
height:
100px;
background: blue;
}
.left {
position: absolute;
left:
0;
top:
100px;
bottom:
50px;
width:
200px;
background: red;
}
.right {
position: absolute;
left:
200px;
top:
100px;
bottom:
50px;
right:
0;
background: pink;
overflow:
auto;
}
.right .inner {
min-height:
1000px;
}
.bottom {
position: absolute;
left:
0;
right:
0;
bottom:
0;
height:
50px;
background: black;
}
</style>
</head>
<body>
<div class="top">
top
</div>
<div class="left">
left
</div>
<div class="right">
<div class="inner">
right
</div>
</div>
<div class="bottom">
bottom
</div>
</body>
</html>
效果图


本文介绍了一种使用CSS position属性实现全屏布局的方法,通过绝对定位元素到页面四角,实现了一个包含顶部、左侧、右侧和底部区域的响应式布局。顶部和底部固定高度,左侧宽度固定,右侧内容区自动填充剩余空间。
548

被折叠的 条评论
为什么被折叠?



