示例工程 11-positioning

11-positioning/demo-02-fixed-sticky/index.html

html · 0.7 KB

运行:fixed 与 sticky

点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。

<!doctype html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>fixed 与 sticky</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <h1>fixed 与 sticky</h1>
    <p>右下角是 fixed 按钮;下方滚动区里是 sticky 标题。</p>
    <div class="scroll">
      <h2 class="sticky">粘性标题</h2>
      <p>内容一</p><p>内容二</p><p>内容三</p><p>内容四</p><p>内容五</p>
      <p>内容六</p><p>内容七</p><p>内容八</p><p>内容九</p><p>内容十</p>
    </div>
    <button class="fixed" type="button">fixed</button>
  </body>
</html>