关于position的一些问题

 position属性:
  static:静止
  relative:相对的
  fixed:固定的
  absolu:绝对的

position的一些实例子如下:

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="./CSS文件/例子6.css">
</head>
<body>
        <div class="box" id="one">One</div>
        <div class="box" id="two">Two</div>
        <div class="box" id="three">Three</div>
        <div class="box" id="four">Four</div>
        <div id="id"></div>
       
   
</body>
</html>
CSS:
.box {
    100px;
    height: 100px;
    background: red;
    color: white;
  }
  #one{
    position: static;
  }
  #two {
    position: relative;/*relative的位置是基于原来的位置*/
    top: 1000px;
    left: 20px;
    background: blue;
  }
  #three{
      position: fixed;/* fixed简单描述:固定定位是将某个元素固定在浏览器的某个确定的位置,不随滚动条的移动而变化;

      注意:固定定位的位置是相对于前一个位置的;*/
      top: 200px;
      left: 500px;
      background: yellow;
  }
  #four{
    position: absolute;/*absolute相对于前一个位置的*/
    top: 20px;
    left: 700px;
  }
 
 
 
原文地址:https://www.cnblogs.com/gogogoing/p/9703880.html