Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Align an image using CSS

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #23038
    bancom
    Participant

    Hi I would like to center all the images in in my sidebar div but I dont know the code to do this. I know to use

    Code:
    text-align: center;

    for centering text but not for an image.

    Here is what I have got so far:

    Code:
    #sidebar {
    clear:right;
    float:left;
    font-size:12px;
    padding-left:15px;
    text-align:left;
    width:246px;
    }

    #sidebar img {

    }

    #48865
    ThinkSoJoE
    Member

    this is just a guess, and I could be completely wrong (it’s all trial and error for me, so I’m still learning what works and what doesn’t); but try this:

    Code:
    #sidebar img {
    margin: 0 auto;
    }
    #48869
    james.davis
    Member

    What has worked for me with aligning images especially in the sidebar has been setting it as the background-image. This maybe a newbie move being I just completed my first CSS site. I just seem to have better flexibility when I do it this way. The text seems to play better as well.

    #48886
    bancom
    Participant

    I used the text-align: center; in my sidebar div which then centered the text.

    Again the god of CSS design has done it.

    Thanks Chris :P

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.