Container to fit to image height when scaled

I have a problem.

I would like a container div within a slider that holds an image and text that is:
Scaled to 100%vh with margins top and bottom of 40px
Images scale down as height is decreased.
But, the text stays below within the same width bounds of the image ie. the container scales to the width of the image and the text flows with it.
Added to this I would like the bounding div to remain central.

Having trouble with this as it is in a slider with a cms collection!

Driving me mad!