WordPress.org

Ready to get started?Download WordPress

Forums

Problem with center image (7 posts)

  1. louidam
    Member
    Posted 6 months ago #

    Hi,

    I would like all my images to be centered in my blogposts. What should I write in the css?

    Many of the images I have given the <center> tag, but it would be nice if could be written in the css?

    Here is a post, where it isn't centered: http://www.louisesmadblog.dk/2012/10/laekre-scones-med-chokolade.html

    Thanks for your help!

    /Louise

  2. Cindy Vriend
    Member
    Posted 6 months ago #

    you shouldn't have to rewrite the css. Basically when you add an image to a post (via add media) it should give you the option to select alignment (left, right, center and none)

  3. Cindy Vriend
    Member
    Posted 6 months ago #

    If you do want to do it through your CSS find this in your stylesheet:

    .post img {
    max-width: 676px;
    margin-bottom: 20px;
    border: none
    padding: 2px;
    }

    try adding

    margin-left:auto;
    margin-right:auto;

  4. louidam
    Member
    Posted 6 months ago #

    I always insert pictures in the html and I upload my pictures til flickr and not to wordpress. So I can't just select the alignment.

    The code did not work, unfortunately :-(

  5. Cindy Vriend
    Member
    Posted 6 months ago #

    :) I think there's a little misunderstanding...

    I think you write the blogpost with wordpress and then when you want to insert a picture you click on insert/add media and then you select the image you want to place in the blogpost.

    When you do it like this you will get an option to choose the alignment (left, right, center or none)

    like explained (with screenshots) here in the wordpress codex

  6. Cindy Vriend
    Member
    Posted 6 months ago #

    I just saw you're using a child theme. So if you want to do it with CSS you might have to use it like this

    .post img {
    max-width: 676px;
    margin-left:auto !important;
    margin-right:auto !important;
    margin-bottom: 20px;
    border: none
    padding: 2px;
    }

  7. louidam
    Member
    Posted 6 months ago #

    Hi again,

    I did understand you at first. But I do not use the button add media when I write a post. I just write the html code direct in the post.

    This code did not work. It's strange.

Reply

You must log in to post.

About this Topic