<!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>css</title> <style> .father { /* 父盒子相对定位 */ position: relative; width: 90px; height: 90px; background-color: red; } .son { /* 子盒子绝对定位 */ position: absolute; right: -8px; top:-8px; width: 20px; height: 20px; background-color: green; } </style> </head> <body> <div class="father"> <div class="son"></div> </div> </body> </html>
运行图片:
标签:盒子,color,子绝,width,background,父相 From: https://www.cnblogs.com/huguo/p/17286525.html