Try to find out how the function works, that will save you lots of time in the future. I see you've got more questions about the very same function, which all wouldn't have been necessary if you already knew how it worked.
(Sorry, in case you didn't realise, that was tongue in cheek. Because the same thing is true for every other question here on StackOverflow!)
Anyway, the trick is to make the outer div position:relative
so that the inner divs are positioned in the same spot. Then all you need to do is put them in the middle, for instance by setting the line-height
to the same value as the height of the image. And with absolute positioning, you won't need the z-index
.
Resulting fiddle here