Place figcaption vertically in the center and next to the image?

I have an image and a caption in the tag figure. I was wondering how I can set figcaptionnext to imgand vertically center, for example, an attached image.

enter image description here

Here's the jsfiddle I installed.

Thanks!

+4
source share
1 answer

Here you go, just replace css with the following:

html { font-family: 'Helvetica-Neue', Arial, Helvetica; font-size: 1em; line-height: 1.4; letter-spacing: 1px; color:white; }
figure { float:left; padding:20px; display:block; background:#ffa2df; position:relative; }
.width { width:50%; }
.height { height:15em; }
img { width:auto; height:100%; float:left;}
figcaption { background:#5800ff; height:100%; display:flex; justify-content: center;
flex-direction: column;
text-align: center; 
float:left; 
}
+3
source

Source: https://habr.com/ru/post/1622037/


All Articles