Forum How do I...?

image captions not center aligned

stigtors
hi, I have trouble with the alignment of my image captions. I try to center align at bottom of image, but they are all left aligned and also over two lines:

Figure:
1


I use the same approach for my table captions, but they work as intended.

My CSS:

img:after {
	content: "Figure: " counter(figure_counter);
	counter-increment: figure_counter;
	display: table-caption;
	caption-side: bottom;
	font-style: italic;
	text-align: center;
}


By removing the display property the caption is thrown at the bottom right of the image with the figure number at the next line (left side).

All hints appreciated...
mikeday
Hi,

display: table-caption will only work if the box is inside an actual table, it doesn't apply to images in the same way. Perhaps try setting "display: table" on the image itself? Or use different markup.

Best regards,

Michael
stigtors
That worked out fine! Thank you!
/stig