css 居中 一个。
源码
<!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> </head> <body style="width: 100%;height: 100%;"> <div class="box"> </div> <style> .box { width: 500px; height: 300px; position: absolute; top: 50%; left: 50%; margin-left: -250px; margin-top: -150px; background-color: red; } </style> </body> </html>