tags:

views:

170

answers:

5

Now i try

<html>
<head>

        <title>?????????????????</title>
        <style type="text/css">   
    body
    {

            margin-left: auto;
            margin-right:auto;
    }

    #wrap
    {
            background: black;
            margin-left: auto;
            margin-right:auto;
            height:450px;
            width:450px;
            position:absolute;
            top:50%;
            right:50%;
            left:50%;
            margin-top:-225px;
         }
    </style>
</head>
<body>
        <div id="wrap">
                Hello
        </div>
</body>
</html>

?????

+3  A: 

vertical-align does not work the way most beginners expect it to work.

Here is one tutorial explaining the situation. It sounds like you want Method 1.

Jon Purdy
sorry i am newb what i do?
John Nall
I would advise you click the link and do what it tells you to do.
Eric
A: 
mike clagg
isnt vertical center?
John Nall
A: 

This tutorial covers a method that has worked well for me in the past.

warrenm
A: 

People may hate me for suggesting this, but place it within a TD, where vertical-aligning is still doable without inflicting any harm on yourself.

I've provided a working examples here: http://jsbin.com/ezolu3/edit

The markup follows:

<table id="vCent">
  <tbody>
    <tr>
      <td valign="center">

        <div id="foo">
          <p>Using tables incorrectly is wrong, without question. But sometimes there are other things that are more wrong - "wrongerer," if you will. Causing yourself unnecessary frustration trying to get an element to center itself vertically, for example, is one of those <em>wrongerer</em> things. Don't bother, just go with what works.</p>
        </div>

      </td>
    </tr>
  </tbody>
</table>
Jonathan Sampson
A: 

Try this:

<html>
    <head>
        <title>?????????????????</title>
        <style type="text/css">
        #content
        {
            background: black;
            margin: -225px;
            height: 450px;
            width: 450px;
        }
        #wrap
        {
            height: 0px;
            width: 0px;

            position:absolute;
            top:50%;
            left:50%;
        }
        </style>
    </head>
    <body>
        <div id="wrap">
            <div id="content">
                Hello
            </div>
        </div>
    </body>
</html>
Eric