元素居中
<!doctype html> <html> <head> <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"> <meta charset="utf-8"> <title></title> <style> #center{ width:200px; height:200px; position:absolute; top:50%; left:50%; margin-top:-100px; background:red; margin-left:-100px; } </style> </head> <body> <div id="center"></div> </body> </html>