定位:
四种模式:static(文档流),relative(相对定位),avsolute(绝对定位),fixed(固定定位)
四个位置:left、right、top、bottom
案例:
完成一个四方形魔盒排序:
完成效果:
代码部分:
实例
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> </title> <style type="text/css"> .box1{ height: 200px; width: 200px; background: #000000; position: relative; top: 200px; } .box2{ height: 200px; width: 200px; background: #87CEFA; position: relative; top: -200px; left: 200px; } .box3{ height: 200px; width: 200px; background: #FFA500; position: relative; left: 200px; } .box4{ height: 200px; width: 200px; background: #FF0000; position: relative; top: -400px; left: 400px; } </style> </head> <body> <div class="box1"></div> <div class="box2"></div> <div class="box3 "></div> <div class="box4"></div> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例