WordPress.org

Support

Support » Themes and Templates » center images on attachment pages

center images on attachment pages

  • 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!

Viewing 14 replies - 1 through 14 (of 14 total)
  • 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.

    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

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

    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.

    WPyogi

    @wpyogi

    Forum Moderator

    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

    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/

    WPyogi

    @wpyogi

    Forum Moderator

    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

    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

    esmi

    @esmi

    Forum Moderator

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

    Does your theme include an image.php template file?

    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

    WPyogi

    @wpyogi

    Forum Moderator

    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%;
    }

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

    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…

    WPyogi

    @wpyogi

    Forum Moderator

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

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘center images on attachment pages’ is closed to new replies.
Skip to toolbar