Archived topic
Image Caption Centered
7 replies · Started by Jack Heape on May 19, 2015
What code should I use to center the caption on an image? I tried this...
.wp-caption .wp-caption-text {
padding: 8px 10px;
margin: 0;
text-align: center;
background: url('images/blk_trans.png');
color:#FFF;
position:absolute;
bottom: 0;
left: 0;
}
but it didn't work. I read the post on the caption below an image, but all I want is for the text in the caption to be centered in the image, not aligned left.
Give this CSS a try:
.wp-caption .wp-caption-text {
width: 100%;
text-align: center;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
Worked great! Thanks. The caption is outside the image now but that is fine.
Hmm it shouldn't be - can you link me to a page with it so I can see?
Did you perhaps replace the core styling (in your first post) with what I added above?
All core CSS should be left alone - making changes to that stylesheet will result in you losing all of your modifications when you update WordPress.
All custom CSS should go in a child theme or a custom CSS plugin: http://generatepress.com/knowledgebase/adding-css/
Let me know :)
Voila'!
I used simple css and made all your suggested changes. Everything seems to be working fine now.
Thanks!
You're welcome! :)