SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Best Way to Center Two Adjacent Images?

    I've got two side-by-side images I need to be centered in their container. I don't know any way of doing this that doesn't seem like a hack.

    need something like this (x's are the two images): |----xx----|

  2. #2
    Life is not a malfunction gold trophysilver trophybronze trophy
    TechnoBear's Avatar
    Join Date
    Jun 2011
    Location
    Argyll, Scotland
    Posts
    6,408
    Mentioned
    273 Post(s)
    Tagged
    5 Thread(s)
    In order to help you with your problem, we need to see the code you're using. Please provide a link to the site, or if you can't do that, paste the HTML and CSS for the page here. Wrap [CODE] tags round it (you can "Go Advanced" and use the # button to do this), to make sure it's properly formatted and easy to read.

  3. #3
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,892
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    Is there anything else in the container with them? If not, how about {text-align:center;} on the container? If there is, wrap them in a <div> with {text-align:center;}.

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stevie D View Post
    Is there anything else in the container with them? If not, how about {text-align:center;} on the container? If there is, wrap them in a <div> with {text-align:center;}.
    Thanks, that gets the job done. I wouldn't have thought to use "text" align like that. Is that ok/normal practice or is it a hack? Cause... well, you know... it's not text .

  5. #5
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,892
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Fretman View Post
    Thanks, that gets the job done. I wouldn't have thought to use "text" align like that. Is that ok/normal practice or is it a hack? Cause... well, you know... it's not text .
    If the images are inline (ie, not positioned or floated) then they behave just like text, so you can align them, underline them and so on. Remember that you could just as easily have had text mixed in with the images, rather than just two images on their own, and you wouldn't think twice about using text-align then.

  6. #6
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stevie D View Post
    If the images are inline (ie, not positioned or floated) then they behave just like text, so you can align them, underline them and so on. Remember that you could just as easily have had text mixed in with the images, rather than just two images on their own, and you wouldn't think twice about using text-align then.
    I see, thanks.


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
  •