I've looked at a googol google results without finding any that work.
I need to have my div (height 333 px, width 550 px) to be centered horizontally and always be 275 px from the top. Every time I try to do this it just disappears.
I've looked at a googol google results without finding any that work.
I need to have my div (height 333 px, width 550 px) to be centered horizontally and always be 275 px from the top. Every time I try to do this it just disappears.
If the div should sit on top you have to use position:absolute
. Otherwise, the answer from @sdleihssirhc should work.
#middlebox
{
position: absolute;
top: 275px;
left: 50%; /* move the left edge to the center … */
margin-left: -275px; /* … and move it to the left half the box’ width. */
z-index: 9999; /* Try to get it on top. */
}
Use tools like Dragonfly or Firebug to inspect the properties if it still disappears.
Depending on the content and context, you could just set that div's margin:
margin: 275px auto 0;
Unless you're thinking of static positioning, I don't think that you would need to use absolute positioning at all. Try this:
<html>
<head>
<title>Test</title>
</head>
<body>
<div style="width:550px; height:333px; background-color:orange; margin: 275px auto">
Is this what you want?
</div>
</body>
</html>