Archived topic
How Can I Center Image Caption in Generatepress With Mobile Displays?
7 replies · Started by Colton on September 6, 2021
I've found this CSS which has helped to center images that are aligned left or right but the text caption below any image is still not centered.
@media (max-width: 769px) {
.wp-block-image .alignright {
display: block;
float: none;
margin-right: 0;
text-align: center;
}
}
Is there a way to be able to use CSS to get my captions centered?
Thank you for any help! I appreciate it! 😊
Hi there,
Do you want to apply it on ALL text captions? or perhaps selected/specific ones?
If you want on a specific text, can you link us to the page in question?
If you want to apply it on all text captions of image blocks, try adding this CSS:
.wp-block-image .alignright figcaption {
text-align: center;
}
But I highly suggest aligning it center through Block Editor instead of doing this. :D
Hi Elvin,
I have the same question. I'd rather use the block editor to do this but I can't find the option. My page isn't live yet so I'm unable to share the URL.
I'm building a 3-column shop page. Each column will have an image with a shop button beneath the image. The image and the button are centered, but the caption is left-aligned. I can't find the option to change the caption to be center-aligned. Here is a screenshot of my page in progress.
Image
Thank you,
Kelsey
Hi Kelsey,
GeneratePress 3.1.2 has a CSS that set this to center by default -
https://github.com/tomusborne/generatepress/blob/5625e4de9fc110000192c3afffb59b90d17172e3/assets/css/main.css#L1017-L1020
But this can be overwritten if you have custom CSS or any plugin that overrides this.
Can you link us to the page where this is added? to check and confirm this.
Hmmm...I don't have any custom CSS that would conflict with what you posted. Does it matter if this is on a page vs a post?
Hmmm…I don’t have any custom CSS that would conflict with what you posted. Does it matter if this is on a page vs a post?
It shouldn't as the same selector is used for the image block's caption regardless of post type. :D
Thanks, Elvin. It's working for me now for some reason. I appreciate your help.
No problem. Glad to be of any help. :D