WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Problem with centered images and links (3 posts)

  1. Anna Johansson
    Member
    Posted 5 years ago #

    Using .aligncenter on a linked image only centers the image and not the link. I.e. the whitespace of the entire paragraph is linked, not just the image.

    You can see an example on it here.

    Using the ordinary .aligncenter {display:block;margin:0 auto} css.

    Any ideas on how to prevent this?

    update: It only seems to behave this way in FF though...

  2. chaoskaizer
    Member
    Posted 5 years ago #

    it need a fixed dimension so you must set the width prop for the linked image, update your theme's style.css.

    find

    img.aligncenter {display: block; margin:1em auto; text-align:center}

    replace with

    img.aligncenter,.aligncenter {display: block; margin:1em auto; text-align:center}

    and apply the aligncenter class on link

    <a ... class="aligncenter" style="width:300px"><img ../></a>
  3. Anna Johansson
    Member
    Posted 5 years ago #

    Ah, so obvious now that you tell me...

    Big thank you for that! =)

Topic Closed

This topic has been closed to new replies.

About this Topic