码迷,mamicode.com
首页 > Web开发 > 详细

CSS布局

时间:2019-11-10 19:21:27      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:abs   uip   absolute   top   out   lan   gre   title   osi   

<!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>

 

CSS布局

标签:abs   uip   absolute   top   out   lan   gre   title   osi   

原文地址:https://www.cnblogs.com/tasly/p/11831296.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!