Set div to sibling's width

Hi! I’m trying to make a CMS carousel where a caption is set to the width of a dynamically sized photo, but I’m having trouble. Anyone know a good workaround?

Basically I want it like this:

Link (relevant part is in the homepage in the “art” carousel):
https://preview.webflow.com/preview/portfolio-2-2ccaee?utm_medium=preview_link&utm_source=designer&utm_content=portfolio-2-2ccaee&preview=e724b322a5cd2bbedc33b1dec5022b16&mode=preview