日期:2014-05-17  浏览次数:20834 次

css控制div绝对居中问题

<!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>
<title> Matching Game </title>
<meta name="generator" content="editplus" />
<meta name="author" content="lijunliang" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<style>
html,body{
	height:100%;
}
.wrapper{
	height:100%;
}
.left{
	width:300px;
	margin-right:-300px;
	background-color:yellow;
	height:100%;
	float:left;
}
.right{
	margin-left:300px;
	background-color:black;
	height:100%;
	position:relative;
}
.centerit{
	height:200px;
	width:300px;
	top:50%;
	left:50%;
	position:absolute;
	background-color:white;
	margin-top:-100px;
	margin-left:-150px;
}
</style>
</head>
<body>
	<div class="wrapper">
		<div class="left"></div>
		<div class="right">
			<div class="centerit">
				<div class="inner">
					i am in the center
				</div>
			</div>
		</div>
	</div>
</body>
</html>
?