css3基础---绝对定位模拟固定定位

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }

      html {
        overflow: hidden;
        height: 100%;
      }

      body {
        overflow: hidden;
        height: 100%;
      }

      .wrap {
        height: 100%;
        overflow: auto;
      }

      .huak {
        height: 2000px;
      }

      .fk {
        width: 100px;
        height: 100px;
        /* 给这个元素设置的绝对定位会去根据视口的位置定位 */
        position: absolute;
        top: 0;
        left: 0;
        background-color: pink;
      }
    </style>
  </head>
  <body>
    <div class="wrap">
      <div class="fk"></div>
      <div class="huak"></div>
    </div>
  </body>
</html>

 

上一篇:带进位与溢出符的n位加法器的另一种描述


下一篇:个人自学前端7-CSS2