It’s not clear, to me, what you are trying to do here.
Overlay text on an image?
If so, as long as your text is short enough so that it’s wrapping element is no larger than the image you should be fine.
If you’re trying to squeeze to much text into a div that is larger than the size of the image then CSS won’t help. CSS can only style what’s there, it can’t detect content….if that is the case, you’d need javascript.