div在屏幕的正中央

最初发表于: 2020-04-25 12:12:44

示例代码如下

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>Login</title>
	<link rel="stylesheet" href="">
	<style type="text/css" media="screen">
	* {
		margin:0;
		padding:0;
	}	

	.login{
		width:440px;
		height:375px;
		border:1px solid red;
		/*以下是重点*/
		position: fixed;
    		top: 0px;
    		left: 0px;
    		right: 0px;
    		bottom: 0px;
    		margin: auto;
	}
	</style>
</head>
<body>
	<div class="login">
	
		
	</div>
</body>
</html>