Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17
  1. #11
    Join Date
    May 2008
    Posts
    1,160
    Tokens
    11

    Latest Awards:

    Default

    Use this, like said earlier.

    Code:
    #div {
            margin: auto;
           }
    Previously a Habbo fanatic, web designer/developer, fansite owner, & trusted member of the community.

  2. #12

    Default

    Because it doesn't work, try it yourself it only works for horizontal.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    
    <style type="text/css">
    #middle
    {
      width: 200px;
      margin: auto;
      background-color: #333;
    }
    </style>
    
    </head>
    <body>
    
    <div id="container">
      <div id="middle">
        Expands yay :)<br />
        <br />
        <br />
        <br />
        and yet not centered vertically :(
      </div>
    </div>
    
    </body>
    </html>
    even with a fixed container
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    
    <style type="text/css">
    #container
    {
      width: 600px;
      height: 600px;
      background-color: #999;
    }
    
    #middle
    {
      width: 200px;
      margin: auto;
      background-color: #333;
    }
    </style>
    
    </head>
    <body>
    
    <div id="container">
      <div id="middle">
        Expands yay :)<br />
        <br />
        <br />
        <br />
        and yet not centered vertically :(
      </div>
    </div>
    
    </body>
    </html>
    thus proving it does not WORK! for vertical aligning.
    Last edited by Iszak; 25-10-2008 at 09:30 PM.

  3. #13
    Join Date
    Jul 2008
    Location
    Hastings, UK.
    Posts
    2,050
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Favourtism View Post
    When I asked before for alligning divs in a skin I got told to use

    v-align: center;
    Sorry, but what's with your signature,

    $variable_function();

    You can't do that, lol.

    On topic:

    <center> and </center>

    but it's not valid xhtml.

  4. #14
    Join Date
    Jun 2008
    Location
    Manchester
    Posts
    766
    Tokens
    0

    Default

    Quote Originally Posted by craigg. View Post
    use margin: auto; on the container div or even in the body tag.
    Quote Originally Posted by Cushioned View Post
    Use this, like said earlier.

    Code:
    #div {
            margin: auto;
           }
    That had already been said twice, so pointless posts.

    Quote Originally Posted by Calon View Post
    On topic:

    <center> and </center>

    but it's not valid xhtml.
    You didn't even read the topic.
    "Best way of Vertical centering a div?"

  5. #15
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    Quote Originally Posted by Iszak View Post
    Jxhn is right to an extent in using vertical align, but for it to work you must set the parent/containing div to be display: table-cell; here is an example.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    
    <style type="text/css">
    #container
    {
      width: 500px;
      height: 500px;
      display: table-cell;
      vertical-align: middle;
      background-color: #333;
    }
    
    #middle
    {
      width: 500px;
      background-color: #999;
    }
    </style>
    
    </head>
    <body>
    
    <div id="container">
      <div id="middle">
        Expands yay :)<br />
        <br />
        <br />
        <br />
        and yet still centered :P:
      </div>
    </div>
    
    </body>
    </html>
    Now if you want something centered vertically in the body now that's a different story.


    I might also add on Jxhn first post about the position: absolute; left: 50%; margin-left: -(width/2)px of course you don't do it like that you do the calculations this has one slight problem - you've got to set the parent to position: relative; otherwise it'll fail.
    That worked the best

    I had to change the container to display:table and the middle to display:table-cell because there were 3 containers next to each other acting like cells

    Anyways, +rep to everyone who helped

  6. #16
    Join Date
    Jul 2008
    Location
    Hastings, UK.
    Posts
    2,050
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Jxhn View Post
    That had already been said twice, so pointless posts.


    You didn't even read the topic.
    "Best way of Vertical centering a div?"
    Yes I did.

    Code:
    v-align: top;
    v-align: bottom;
    is how v-align I thought was used and I thought that he just wanted it centered, excuse my mistake.

    -REP (Need to spread, won't forget..)

  7. #17
    Join Date
    Jun 2008
    Location
    Manchester
    Posts
    766
    Tokens
    0

    Default

    Quote Originally Posted by Calon View Post
    Yes I did.

    Code:
    v-align: top;
    v-align: bottom;
    is how v-align I thought was used and I thought that he just wanted it centered, excuse my mistake.

    -REP (Need to spread, won't forget..)
    You only said center? He said vertical alignment. You can't -rep me because you misread his post. I don't even understand the second sentence, could you rephrase it please?

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •