HabboxWiki needs you!
Are you a Habbo buff? Or maybe a rare trader with a bunch of LTDs? Get involved with HabboxWiki to share your knowledge!
Join our team!
Whether you're raving for rares, excited for events or happy helping, there's something for you! Click here to apply
Need a helping hand?
Check out our guides for all things to help you make friends, make rooms, and make money!


Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    1,734
    Habbo
    Moh

    Latest Awards:

    Default Exactly centered div?

    Is there a way to make a div exactly in the middle? Possibly using JavaScript?

  2. #2
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default

    HTML Code:
    <style type="text/css">
    .Name
    {width: 400px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
    }
    </style>
    <div class="Name">Hi!</div>
    That should work
    Lets set the stage on fire, and hollywood will be jealous.

  3. #3
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    1,734
    Habbo
    Moh

    Latest Awards:

    Default

    Quote Originally Posted by Tom743 View Post
    HTML Code:
    <style type="text/css">
    .Name
    {width: 400px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
    }
    </style>
    <div class="Name">Hi!</div>
    That should work
    Humm, I need it centered x & y
    On msn some one told me to use moveDialogToCenter, but I can't find the source.

  4. #4
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    Here this should work, sorry if it doesn't!

    Code:
    <!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" lang="en" xml:lang="en">
    <head>
    <title>Exactly Centred Div</title>
    
    <style type="text/css">
    
    html {display:table; height:100%; width:100%; margin: 0px; padding: 0px; }
    
    body { display:table-cell; text-align:center; vertical-align:middle; margin: 0px; padding: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 10px; font-weight: bolder; color: #333333; }
    
    .centerdiv { position: fixed; width: 400px; height: 200px; margin-left: -200px; margin-top: -100px; top: 50%; left: 50%; background-color: #cccccc; } 
    
    
    </style>
    </head>
    
    <body>
    
        <div class="centerdiv">
            YOUR TEXT OR OBJECT CAN GO HERE, BUT AN OBJECT CAN'T BE LARGER THAN THE FIXED SIZE. SEEMS TO WORK CROSS BROWSER.
        </div>
    
    </body>
    </html>
    Last edited by Source; 20-04-2008 at 02:51 PM.


    www.fragme.co = a project.

  5. #5
    Join Date
    Apr 2008
    Location
    Fareham
    Posts
    87
    Tokens
    2,716

    Latest Awards:

    Default

    Do you mean the content inside the div exactly in the middle of the div or the divin the middle of the page?
    Forever on the dance floor.

  6. #6
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    the code I posted always puts the DIV in the centre of the page.


    www.fragme.co = a project.

  7. #7
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default

    You should just use the <center> tag lool, and put style="text-align: left;" in the div tag.
    Lets set the stage on fire, and hollywood will be jealous.

  8. #8
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    Yes, but if you re-read the post he states he wanted not only aligned centrally in horizontal terms, but also verticle.


    www.fragme.co = a project.

  9. #9
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    1,734
    Habbo
    Moh

    Latest Awards:

    Default

    Quote Originally Posted by GasFMatt View Post
    Here this should work, sorry if it doesn't!

    Code:
    <!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" lang="en" xml:lang="en">
    <head>
    <title>Exactly Centred Div</title>
    
    <style type="text/css">
    
    html {display:table; height:100%; width:100%; margin: 0px; padding: 0px; }
    
    body { display:table-cell; text-align:center; vertical-align:middle; margin: 0px; padding: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 10px; font-weight: bolder; color: #333333; }
    
    .centerdiv { position: fixed; width: 400px; height: 200px; margin-left: -200px; margin-top: -100px; top: 50%; left: 50%; background-color: #cccccc; } 
    
    
    </style>
    </head>
    
    <body>
    
        <div class="centerdiv">
            YOUR TEXT OR OBJECT CAN GO HERE, BUT AN OBJECT CAN'T BE LARGER THAN THE FIXED SIZE. SEEMS TO WORK CROSS BROWSER.
        </div>
    
    </body>
    </html>
    That code works, but I need it centered screen, not centered page.
    You can see here.

  10. #10
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default

    make a table

    <table>
    <tr><td width="100%" height="100%">
    <center>

    your content here

    </center>
    </td>
    </tr>

    That will work
    Lets set the stage on fire, and hollywood will be jealous.

Page 1 of 2 12 LastLast

Posting Permissions

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