图片在水平上居中的原理

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>图片水平居中原理</title>
	<style type="text/css">
		.picture{
			width:500px;
			height:500px;
			background:url("1.jpg")	no-repeat;
			position: fixed;
			left: 50%;
			top:50%;
			margin-left: -250px;/*将图片左移250px*/
			margin-top: -250px;/*将图片上移250px*/
		}
	</style>
</head>
<body>
	<div class="picture"></div>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/zerobaek/article/details/78137300