The dialogue div element is aligned vertically and horizontally, no matter what the size of the browser window.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>
<head>
<title>Vertical and Horizontal Alignment</title>
<style type='text/css'>
body {
background: lightyellow;
font: 16px sans-serif;
}
div#dialogue {
position: absolute;
width: 200px;
height: 100px;
background: yellow;
border: 1px solid gold;
top: 50%;
left: 50%;
margin: -56px 0 0 -106px;
padding: 5px;
}
p {
margin: 0;
}
</style>
</head>
<body>
<div id='dialogue'>
<p>
The dialogue <div> element is aligned vertically and
horizontally, no matter what the size of the browser
window.
</p>
</div>
</body>
</html>
Related examples in the same category