<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="css/reset.css"> <style type="text/css"> html,body{ 100%; height:100%; position: relative; background-color: #7a43b6; } .container { 85%; height: 85%; position: absolute; left: 0; top: 0; right: 0; bottom: 0; margin: auto; background-color: #00b3ee; } .content{ 85%; height:85%; position: absolute; left: 0; top: 0; right: 0; bottom: 0; margin: auto; background-color: #4cae4c; } </style> </head> <body> <div class="container"> <div class="content"></div> </div> </body> </html>
复制直接运行即可