Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Senior Member Damien's Avatar
    Join Date
    Apr 2004
    Location
    Essex, UK
    Posts
    110
    Member #
    5528
    I want to centre everything on a page? There is a h1, and two divs I want to centre. I want them to stay in the center when page is resized

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Hey.

    In IE, you need a outer div with a style text-align: center;.
    In almost all other browsers, you use margin: 0px auto;

    In my example, I have both (centers in IE and Mozilla based browsers).

    See attatched file.

    Hope this helps.

  4. #3
    Senior Member Damien's Avatar
    Join Date
    Apr 2004
    Location
    Essex, UK
    Posts
    110
    Member #
    5528
    still wont work. It is a img contained in a div, some links in another div. And i want them to be centered both vertically and horizontally

  5. #4
    Senior Member Rince's Avatar
    Join Date
    Nov 2004
    Posts
    183
    Member #
    8318
    Code:
    <body>
    <div id="wrapper" style="position:absolute; top:50%; left:50%; width:400px; height:400px; margin:-200px 0px 0px -200px">
    <div id="image">
    <img src="your_image.gif">
    </div>
    <div id="links">
    <a href="links.html"> link </a>
    <a href="links.html"> link </a>
    <a href="links.html"> link </a>
    </div>
    </div>
    </body>
    Just make sure the margin is negative half the width/height.

    Or else,
    Code:
    <div id="wrapper" style="width:400px; height:400px; margin:auto;">
    But only if there is nothing else in the page outside of #wrapper div else it will only center horizontally and not vertically.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:56 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com