Skip to content

Instantly share code, notes, and snippets.

@mofelee
Last active September 23, 2015 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mofelee/d4d9f70a33b58c5cfc8e to your computer and use it in GitHub Desktop.
Save mofelee/d4d9f70a33b58c5cfc8e to your computer and use it in GitHub Desktop.
把一个层定位在屏幕中间
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>层定位在屏幕中间</title>
<style type="text/css" media="screen">
*{margin:0;padding:0;}
body,html{height:100%;overflow:hidden;}
.body{height:100%;overflow:auto;}
.center{position:absolute;width:120px;height: 120px;left: 50%;top: 50%;margin: -60px 0px 0px -60px;border: 1px solid #F00;}
</style>
</head>
<body>
<div class="body">
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</div>
<div class="center">我在中间</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment