I'm currently up to the problem, that I'm trying to add a caption to an image-element. The caption should wrap if it is larger in width then the image.
<figure class="caption">
<a href="#" target="_blank">
<img src="/sample_image" alt="">
</a>
<figcaption>This is a sample-caption that should wrap if it's width exceeds the width of the image</figcaption>
</figure>
for normal, some CSS-Code like this should do the job:
figure {
display: table;
width: 50px;
}
figcaption {
display: table-row;
}
The problem is, that this doesn't work in combination with the following CSS, used to auto-scale images for mobile devices:
img {
max-width: 100%;
}
So the solution as mentioned here https://stackoverflow.com/a/617455/583569 would not work. I know, that is not a good solution, but for now a conversion of all images into various formats would take to much time.
Is there a possible, non-JS, solution to fix this problem?