HLJ 发布于
2024-03-23 10:50:54
25阅读

div标签指定位置时悬浮固定之css3的position: sticky样式

//此处粘贴代码
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    body {
      height: 2000px;
    }

    div {
      position: sticky;
      top: 0;
      margin-top: 200px;
      background-color: yellow;
      padding: 5px;
      font-size: 16px;
    }
  </style>
</head>

<body>
  <div>div标签到顶部固定住</div>
</body>

</html>
当前文章内容为原创转载请注明出处:http://www.good1230.com/detail/2024-03-23/633.html
最后生成于 2024-06-22 12:07:43
此内容有帮助 ?
0