CSS布局

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>圣杯布局</title>
	<style type="text/css">
		* {
			margin: 0px;
			padding: 0px;
		}
		.container {
			padding: 0px 200px;
			height: 200px;
			background: #eee;
			min-width: 400px;

		}
		.left ,.right {
			width: 200px;
			height: 200px;
			background: red;
			float: left;
		}
		.main {

			width: 100%;
			height: 200px;
			background: blue;
			float: left;
		}
		.left {
			margin-left: -100%;
			position: relative;
			left:-200px;
		}
		.right {
			margin-left: -200px;
			position: relative;
			right: -200px;
		}
	</style>
</head>
<body>
	<div class="container">
		<div class="main">中间</div>
		<div class="left">左边</div>
		<div class="right">右边</div>
	</div>
</body>
</html>

 

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>shuipingchuzhijuzhong</title> <style type="text/css"> * { margin: 0px; padding: 0px; } .box { position: relative; width: 200px; height: 200px; background: lightgreen; } .out { position: absolute; left: 50%; top: 50%; } .in { background: red; margin-top: -50%; margin-left: -50%; } </style> </head> <body> <div class="box"> <div class="out"> <div class="in">内容</div> </div> </div> </body> </html>

 

posted @ 2019-11-10 18:53  糖爱上了盐  阅读(146)  评论(0编辑  收藏  举报