实例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style type="text/css"> .parent { position: relative; border: 1px dashed gray; width: 450px; height: 450px; } .box1 { width: 150px; height: 150px; background-color: lightblue; border-radius: 50%; } .box2 { width: 150px; height: 150px; background-color: lightgray; border-radius: 50%; } .box3 { width: 150px; height: 150px; background-color: lightgreen; border-radius: 50%; } .box4 { width: 150px; height: 150px; background-color: lightcoral; border-radius: 50%; } .box5 { width: 150px; height: 150px; background-color: lightseagreen; border-radius: 50%; } .box1 { position: absolute; left: 150px; border-radius: 50%; } .box2 { position: absolute; top: 150px; border-radius: 50%; } .box3 { position: absolute; left: 300px; top: 150px; border-radius: 50%; } .box4 { position: absolute; left: 150px; top: 150px; border-radius: 50%; } .box5 { position: absolute; left: 150px; top: 300px; border-radius: 50%; } </style> <title>20190705作业,绝对定位小案例(</title> </head> <body> <div class="parent"> <div class="box1"></div> <div class="box2"></div> <div class="box3"></div> <div class="box4"></div> <div class="box5"></div> </div> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例