Files
front-end-example/02-css-layout/10-fixed-and-sticky/starter.html
2026-03-13 23:55:18 +08:00

69 lines
1.7 KiB
HTML

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Fixed 与 Sticky</title>
<style>
body{
background-color: rgb(248, 252, 255);
margin: 0px;
display: flex;
justify-content: center;
align-items: center;
}
a{
text-decoration: none;
color: white;
background-color: rgb(5, 94, 5);
border-radius: 20px;
padding: 10px 20px;
position: fixed;
right: 20px;
bottom: 20px;
font-size: 18px;
}
.page{
width: min(700px,calc(100% - 40px));
margin: 0 auto;
}
.topbar{
padding: 15px;
background-color: white;
position: fixed;
top: 0px;
font-weight: 700;
font-size: 17px;
width: min(700px,calc(100% - 40px));
}
.content{
height: 1100px;
margin-top: 60px;
}
</style>
</head>
<body>
<a class="help" href="#">帮助</a>
<section class="page">
<header class="topbar">学习导航</header>
<div class="content">
<p>向下滚动时观察导航位置。</p>
<p>这里放一些占位内容。</p>
<p>这里放一些占位内容。</p>
<p>这里放一些占位内容。</p>
<p>这里放一些占位内容。</p>
<p>这里放一些占位内容。</p>
<p>这里放一些占位内容。</p>
<p>这里放一些占位内容。</p>
<p>这里放一些占位内容。</p>
<p>这里放一些占位内容。</p>
</div>
</section>
</body>
</html>