Results 1 to 6 of 6

Thread: Position Correctly...

  1. #1
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Position Correctly...

    Heya guys ,

    I did try to find the answer on the web but couldn't and so have turned to here (obviously)...

    This time the problem is that when you position an image your only positioning the top-left-corner, eg when you set top: 50%; left: 50%; it will set the top-left-corner of the image to there and set the rest correctly...

    Please tell me a way to tackle this...

    Thanks

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Are you trying to center the image on a page? If so, you left that part out from your question. If that is what you are trying to do, add a negative left margin that is half the width of the image and a negative top margin that is half the height of the image.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Hmm... I think pcbrainbuster may be talking about the background-position; css property. Either way would do the trick.
    - Mike

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by mburt View Post
    Hmm... I think pcbrainbuster may be talking about the background-position; css property. Either way would do the trick.
    Hardly, if you want to center a background image:

    Code:
    background:url('whatever.jpg') no-repeat center;
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    As you probably know this is just a general question by me as a reference for the future...

    The thing I am confused with is that when you position something you actually mainly positioning the top left corner of the it and so that comes out wrong... (eg if you position something like this in the style attribute top: 50%; left: 50% it will put the top left corner of the thing there and not the center of it...)-

    <html>
    <body>
    <img style="position: absolute; left: 50%; top: 50%;" src="image.ext">
    </body>
    </html>

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by jscheuer1 View Post
    [A]dd a negative left margin that is half the width of the image and a negative top margin that is half the height of the image.
    I had it right the first time.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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