Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2008
    Posts
    464
    Tokens
    0

    Default Getting the image in the centre vertically + horizontally

    Yes, I know what <center> does, so please read before you post.

    I want to get an image to go in the center (vertically and horizontally) of the page. To get it vertically I had to cut the image in two, but what do I do to this to get it to center horizontally? This is the code:

    Code:
    <div style="align: center; margin-left: auto; margin-right: auto; width: 600;">
    <img src="images/splashpostbetatop.png" style="position: absolute; bottom: 50%;"/>
    <img src="images/splashpostbetabot.png" style="position: absolute; top: 50%;"/>
    </div>
    I've added <center> tags but that pushes it towards the right and not the middle. Help!!

    EDIT: This is what it looks like: http://www.tehupload.com/uploads/059...c3901htijt.png
    Last edited by Mickster; 28-09-2008 at 12:00 PM.


  2. #2
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    HTML Code:
    <div style="background-image: url( '<your-full-image>.png' ); background-position: 50% center; background-repeat: no-repeat; width: <your-images-width>px; height: <your-images-width>px; position: absolute; top: 50%; left: 50%; margin-left: -( <your-images-width> / 2 )px; margin-top: -( <your-images-height> / 2 )px;"></div>
    Try that (but make sure to edit the CSS declarations!).
    Last edited by Invent; 28-09-2008 at 12:00 PM.

  3. #3
    Join Date
    Jan 2008
    Posts
    464
    Tokens
    0

    Default

    Just tried it, It makes the image go really far down the page but not in the centre.


  4. #4
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    I made a mistake in my original post - so make sure you are using the code I just changed.

    Also, to make sure you're using the code right use this website as an example: www.pixstudios.net

  5. #5
    Join Date
    Jan 2008
    Posts
    464
    Tokens
    0

    Default

    Quote Originally Posted by Invent View Post
    I made a mistake in my original post - so make sure you are using the code I just changed.

    Also, to make sure you're using the code right use this website as an example: www.pixstudios.net
    I'm sure it's right, but now I get this:

    http://jewbear.net/img/1222604057223.png


  6. #6
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    Upload your image and I'll write the code for you.

  7. #7
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Quote Originally Posted by Mickster View Post
    I'm sure it's right, but now I get this:

    http://jewbear.net/img/1222604057223.png
    imgwidth = width of the image DIVIDED BY 2 (work this out yourself)
    imgheight = height of the image DIVIDED BY 2 (^)

    margin-left: -imgwidth px;
    margin-top: -imgheight px;

    put that in your css where the logo is.

    That should work.


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  8. #8
    Join Date
    Jan 2008
    Posts
    464
    Tokens
    0

    Default

    I fixed it, never mind.


Posting Permissions

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