CSS定位
<style> .div_1{ background: red; position: absolute;/*根据上级绝对定位*/ right: 0px; top: 0px; } .div_2{ background: blue; position:relative;/*相对本身定位*/ top:10px; left:20px; } .div_3{ background: green; position: fixed;/*根据窗体绝对定位*/ right: 50px; top: 50px; } .div_4{ border:1px solid #ffff00; } div{ height: 200px; width: 100px; } input{ border:1px solid blue; } </style>
<body> <div class="div_1"> <span>我是第一个div</span> </div> <div class="div_2"> <span>我是第二个div</span> </div> <div class="div_3"> <span>我是第三个div</span> </div> <div class="div_4"> <span>我是第四个div</span> </div> <input type="text"> </body>