CSS之绝对定位的居中对齐
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>绝对定位的居中对齐</title> <style> div{ width: 200px; height: 200px; background-color: #2288f6; position: absolute; left: 50%; margin-left: -100px; top: 50%; margin-top: -100px; } </style> </head> <body> <div></div> </body> </html>