Centering: Negative Margin

http://www.bluerobot.com/web/css/center2.html

Centering: Negative Margin

This box is horizontally centered using a technique proposed to me by Simon Coggins. First, the box's left edge is positioned at the horizontal center of the page using "position:absolute; left:50%;". Then, the box's left margin is set to the opposite of half the box's width using "margin-left:-266px;".

body {margin:0px; padding:0px;}

#Content {
	position:absolute;
	left:50%;
	width:500px;
	margin-top:50px;
	margin-left:-266px;
	padding:15px;
	border:1px dashed #333;
	background-color:#eee;
	}

你可能感兴趣的:(margin)