123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <!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>
- #div0{
- width: 800px;
- height: 500px;
- background: #ccc;
- /* margin:100px; */
- /* 定位挪走父元素 */
- position: relative;
- left:100px;
- top:100px;
- }
- #div1{
- width: 200px;
- height: 100px;
- background: #f00;
- float: left;
- }
- #div2{
- width: 200px;
- height: 100px;
- background: #00f;
- float: left;
- /* 相对定位 */
- /* position: relative;
- left:200px;
- top:200px; */
- position: absolute;
- left:200px;
- top:50px;
- }
- #div3{
- width: 200px;
- height: 100px;
- background: #0f0;
- float: left;
- }
- #div5{
- width: 100px;
- height:200px;
- background: green;
- position: fixed;
- right:0px;
- bottom: 0px;
- }
- </style>
- </head>
- <body>
- <!--
- 定位: position
- relative相对定位 1、相对于自己初始位置 2、定位后空间不释放
- absolute绝对定位 1、相对于最近已定位的祖先元素,如果没有最近已定位的祖先元素,相对于body
- 2、定位后空间释放
- fixed固定定位 1、相对于页面可视区的位置
- 2、定位后空间释放
- static 静态的 没有定位 默认值
-
- -->
- <div id="div0">
- <div id="div1"></div>
- <div id="div2"></div>
- <div id="div3"></div>
- </div>
- <div id="div5"></div>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- <h1>222222222222222222</h1>
- <h1>111111哈哈哈哈哈哈哈</h1>
- </body>
- </html>
|