木子屋 Dnawo's BLOG

DIV固定浮动在网页顶端或底部代码

👤 dnawo 📅 2014-03-12 👁 13025 👍 0 💬 0 🔄 来源:本站原创
1、DIV固定浮动在网页顶端代码

<div style="position:fixed; top:0; z-index:100">top</div>

说明:要使div里的文本居中,增加“width:100%; text-align:center;”即可(下同)。

2、DIV固定浮动在网页底部代码

<div style="position:fixed; bottom:0; z-index:100">bottom</div>

完整示例

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>DIV</title>
<style type="text/css">body{margin:0; padding:0;}</style>
</head>

<body>
	<div style="position:fixed; top:0; z-index:100;">top</div>
	<div style="height:2000px; background-color:#A8A8B7">hello,world!</div>
	<div style="position:fixed; bottom:0; z-index:100;">bottom</div>
</body>
</html>

评论(0)

暂无评论。

验证码
评论需审核通过后显示
← 上一篇 神舟优雅A480N-i5D3笔记本关机状态USB给手机充电测试 下一篇 → 交通银行信用卡开通账单和大额交易短信提醒示例