位置

 <!doctype html> 
<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>
<style> 
html{background:1px dashed red;} 
body{background:1px dashed blue;} 
 
.box {
  display: inline-block;
   100px;
  height: 100px;
  background: red;
  color: white;
}
#two {
  position: static;
  top: 20px;
  left: 20px;
  background: blue;
}
<!DOCTYPE html>
<html>
<head>
    <title>position</title>
    <style type="text/css">
    body{
        background: #7CF686;
    }
    /*<!--
    #pageHeader{
 
    }静态*/
    -->
 
    /*<!--#pageHeader h2{
        position: absolute;
        left: 200px;
        top: 200px;
    }-->绝对定位*/
     
    /*#pageHeader h2{
        position: relative;
        left: 200px;
        top: 200px;
    }相对定位*/
 
    /*#pageHeader{
        background:#DC1111;
        position:fixed;
         100%;
        top: 200px;
        left: 10px;
    }
    #box{
        height: 2000px;
        background: #725AF0;
    }j固定定位*/
    </style>
</head>
<body>
<div id="pageHeader">
    <h1><span>99999</span></h1>
    <h2><span><acronym title="cascading style sheets">CSS</acronym>11111111</span></h2>
</div>
<div id="box"></div>
</body>
<ml>
absolute:
生成绝对定位的元素,相对于 static 定位以外的第一个父元素进行定位。
元素的位置通过 "left", "top", "right" 以及 "bottom" 属性进行规定。
fixed:
生成绝对定位的元素,相对于浏览器窗口进行定位。
元素的位置通过 "left", "top", "right" 以及 "bottom" 属性进行规定。
relative:
生成相对定位的元素,相对于其正常位置进行定位。
因此,"left:20" static会向元素的 LEFT 位置添加 20 像素。
static:默认值。没有定位,元素出现在正常的流中(忽略 top, bottom, left, right 或者 z-index 声明)。
inherit:规定应该从父元素继承 position 属性的值。
原文地址:https://www.cnblogs.com/tomorrowtodie/p/9716296.html