Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

absolute position from the center of screen horz

Status
Not open for further replies.

cesarcesar

Programmer
Mar 5, 2003
30
Im trying to position a div on the screen but instead of positioning from 0,0, i want to position from the center of my screen. somethig like 50%,50%. i want to do an absolute position from the center of screen horz, and i cant figure it out.

i hope i explained it okay. thanks
 

This will give you a box that is always centred in the browser window:

Code:
<html>
<head>
<style type="text/css">
#central
{
	position: absolute;
	width: 50%;
	height: 50%;
	left: 25%;
	top: 25%;
	background-color: #FF0000;
}
</style>
</head>
<body>
	<div id="central">
		This div will be centred on the screen.
	</div>
</body>
</html>

Hope this helps,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top