Hi! I’ve been struggling with a very similar problem: I’ve had images and captions that i grouped as pairs and anchored into the text. I did not rasterize the text in order to have it flowable. In exporting, ID produces a nice pair of div-tags, one for the image and one for the caption appearing after each other inside another div for them both. Works nice, and you get to style the caption to stand out from the body.
My problem was however that some of the images appeared after the caption, having only some of them appear before the caption as supposed to (even though all images are more to the top left than the captions on the indesign page). I guess this would be easy to fix in the code but as i had quite a lot of pictures it was important to get it right in the first place when exporting from ID.
I found the solution: It’s the object that closer to surface than the other, that will appear first in the code. It did not matter which one, pic or caption, was more to the left or right, top or bottom, only the depth within the layer seemed to matter. So: “Bring to front” all images, and they will appear first and will have the reflowable text appear after them without the need of rasterising the text. Probably quite an obvious rule, but took me half a day to realise this was the problem. I might need to keep a more systematic workflow when problems appear :)
(I’m still working in InDesign CS 6 so I’m not sure if this rule still is valid for more recent versions.)
Laura’s workaround is also something i considered. But doing it like i describe above, you could straight away get both image and caption inside the same div that’s separate from the body text, and you could apply a class and some sticky css rules for that.
But being new to epub styling i have to ask: What are the perfect css rules for doing this, for example always having the image+caption appear on top of a page? What’s the css for “sticky” rules you mention?