Hi - I’d like css code to text-align:center in wordpress captions.
Captions are left-aligned by default. This works to center the caption:
.wp-caption {text-align:center; font:0.8em Arial,sans-serif; line-height:1.1; border:none}
but then all captions are centered! That is, I can choose default left, or my center, but not both. I’ve tried:
.wp-caption.cnt {text-align:center}
and
.wp-caption .cnt {text-align:center}
but neither work. Does anyone know how I can have 2 separate css rules for left-align and center-align?
The problem seems to be I can’t enter class=“cnt” in the html [caption]. Default html in “Edit Post” (it’s alignright because my text wraps to the left of the image):
[caption id=“attachment_70” align=“alignright” width=“365” caption=“etc”]<img class=“size-full wp-image-70” title=“etc” src=“etc” alt=“etc” width=“365” height=“161” />[/caption]
I can’t do this:
[caption id=“attachment_70” class=“cnt” align=“alignright”…
wordpress strips the class out.
I can do this:
<img class="cnt size-full…
But it has no effect on the align of the caption, nor anything else.
This is my css:
/==BEGIN WORDPRESS IMAGES==
Frames+Borders, see http://www.blogfixes.com/wordpress-2-8-image-alignment-problem-center-left-and-right-blog-fix/
see also http://wpgarage.com/css/css-classes-align-images-block-captions/ - .wp-caption p.wp-caption-text
NEXT PARA AFTER IMG MUST HAVE CLEAR - because CLEARFIX does not work in [CAPTION] or IMG/
img.alignleft, div.alignleft {float:left; margin:0 15px 15px 0} /must keep div/
img.alignright, div.alignright {float:right; margin:0 0 15px 15px}
img.aligncenter, div.aligncenter {text-align:center; margin:0 auto}
.wp-caption {font:0.8em Arial,sans-serif; line-height:1.1; border:none}
.wp-caption.cnt {text-align:center}
.wp-caption .cnt {text-align:center}
.wp-caption img {margin-bottom:3px} /space betw img + cap/
/==END WORDPRESS IMAGES==/
thank you! - Val
P.S. I wonder why sitepoint doesn’t have wordpress forum when majority of sites are written in wordpress today, or are in process of switching to wordpress?