Jump to content

Center and middle align div


kurt.santo

Recommended Posts

View source this page: http://www.jlhaslip.com/samples/misc/posit...entereddiv.htmlThis critical part is the CSS here:

#mydiv {	position:absolute;	top: 50%;	left: 50%;	width:30em;	height:18em;	margin-top: -9em; /*set to a negative number 1/2 of your height*/	margin-left: -15em; /*set to a negative number 1/2 of your width*/	border: 1px solid #ccc;	background-color: #f3f3f3;}

And you need to know the div's width and height in order to centre it accurately.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...