WordPress.org

Ready to get started?Download WordPress

Forums

center images on attachment pages (15 posts)

  1. rileybetka
    Member
    Posted 1 year ago #

    Ok this one is so simple it is disgusting - for some reason I can use the property float: right; and the image will go to the right, float: left; will make it go to the left. all I want to do is center the thing - I tried float: middle; and float: center; - neither of these will put it in the center - ALL I WANT TO DO IS CENTER THE DARN IMAGE! should be really easy and I can't figure out why it won't work

    .image-attachment div.attachment img {
    padding-top: 50px;
    display: block;
    height: auto;
    margin: 0 auto;
    max-width: 100%;
    float: center;
    }

    please someone help me before i pull my hair out! THANKS!

  2. Tunbosun Ayinla
    Member
    Posted 1 year ago #

    Kindly make use of this css

    .image-attachment div.attachment img{
    padding-top: 50px;
    display: block;
    height: auto;
    margin 0 auto;
    }

    There float property donesnt have a center value.

    Don't know why you are making use of max-width: 100;

    But the above css code should work.

  3. rileybetka
    Member
    Posted 1 year ago #

    it's still aligned to the left - which part of this css is telling it to be centered?

    I also found this with firebug:
    .entry-content img, .comment-content img, .widget img {
    float: left;
    max-width: 100%;
    }

    when I change it to float: middle; in firebug it will center the image - but then the line disappears - I tried to add that line to my css with float: middle; and it does nothing - I figured there was a reason it was disappearing

  4. rileybetka
    Member
    Posted 1 year ago #

    I don't understand why there isn't just some line you can add to center it...

  5. Tunbosun Ayinla
    Member
    Posted 1 year ago #

    Kindly add this to your css file

    .entry-content img, .comment-content img, .widget img {
    float: none;
    }

    The reason why it wasn't working is that the float property don't have a middle value it is either left, right or none.

    But with the above code it will be fixed.

  6. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    There is no such things as "float: center;" The "margin: 0 auto;" is what automatically centers block level elements.

    See:

    http://www.w3.org/Style/Examples/007/center.en.html

  7. rileybetka
    Member
    Posted 1 year ago #

    I wonder why it isn't working...is it inheriting something from a higher level or something?

    this is the URL:
    http://www.daily-mash.com/testing-54/chinesecookie/

  8. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    Are you using the built in alignment setting when you insert the image - see:
    http://codex.wordpress.org/Inserting_Images_into_Posts_and_Pages#Image_Alignment

  9. rileybetka
    Member
    Posted 1 year ago #

    no - I was hoping that I wouldn't have to select an alignment every time I put a post in - I just want it to always show images on attachment pages in the center...let me try another post to see what happens if I select nothing - I don't think I chose an alignment on that one

  10. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    I just want it to always show images on attachment pages in the center

    Does your theme include an image.php template file?

  11. rileybetka
    Member
    Posted 1 year ago #

    yeah same thing...
    http://www.daily-mash.com/testing75/vintage_stingray_bike/

    interesting to see that my FB comments are also missing - this is giving me a headache!! lol

  12. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    That's because you've added styles to your child theme that are messing up the default CSS - this in particular:

    .entry-content img, .comment-content img, .widget img {
        float: left;
        max-width: 100%;
    }
  13. rileybetka
    Member
    Posted 1 year ago #

    HAH! not sure why that was there to be honest with you - that fixed it - THANK YOU!

  14. rileybetka
    Member
    Posted 1 year ago #

    now can you tell my why my facebook comments are only showing up on one page? lol. For some reason they are only showing on the chinese cookie one...

  15. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    What are you using to show them? A plugin or ?

Topic Closed

This topic has been closed to new replies.

About this Topic