I am struggling with positioning a div that contains an image and a caption. My goal is to make the caption break into a new line when it reaches 95% of the width of the image.
Despite my efforts, I can't seem to achieve this. The text always pushes the image to the left without breaking as intended.
For reference, here is the fiddle I created for this issue: http://jsfiddle.net/hw7t7xyn/1/
The image is positioned with:
right: 0;
top: 10px;
However, due to the length of the text, it shifts to the left.
Additionally, the div.caption
does not seem to inherit the width of its parent div.
If anyone has any insights or solutions, I would greatly appreciate the help. This issue has become quite frustrating for me.
Update: I forgot to mention that I do not know the exact dimensions of the image. Is there a way to resolve this without needing to use JavaScript?