Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #158017
    abisbee
    Participant

    Hi. My image captions are left-aligned, but sometimes I want to center a caption. How can I do this selectively? This is my CSS code for image captions:

    /*Image captions: format
    —————————-*/
    .wp-caption .wp-caption-text {
    margin-bottom: 0.2em;
    padding: 0 5px 5px 5px;
    position: relative;
    text-align: left;
    font-size: 12px;
    }

    Thank you.
    Alice

    #158021
    Skandha
    Participant

    @abisbee: Please post in your site URL where you want to center align the caption.

    Kind Regards,
    Skandha

    #158026
    abisbee
    Participant
    #158032
    Skandha
    Participant

    @abisbee: To center align the image captions selectively
    Go to => Appearance => Customize => Additional CSS and add the following CSS Code.

    #attachment_5562 .wp-caption-text {
          text-align:center;
    }

    This will center align the caption of the first image on this https://wellnesswarriorsboston.org/special-events/
    Like wise if you want to center align the caption of only the second image use the following CSS Code.

    #attachment_5565 .wp-caption-text {
          text-align:center;
    }

    So, different images have different #attachment_ids. You will need to use the ids to selectively center align the captions.

    Hope this helps you out. Have a good day! 🙂
    Kind Regards,
    Skandha

    #158062
    abisbee
    Participant

    Thank you, Skandha. I was hoping that I could do this with html, rather than having to code each caption separately in css. Is it possible to set alignments for all captions on one page through css?
    Alice

    #158225
    Skandha
    Participant

    @abisbee: I’m afraid you will need to add CSS code to selectively center align the captions. If you can let me know which captions you want to center align I could provide you the necessary codes.

    Kind Regards,
    Skandha

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘selective image caption alignment’ is closed to new replies.