CSS 全屏布局使用position

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

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!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>

效果图

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xvzhengyang

感谢,励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值