The phenomenon you're talking about is call chromostereopsis. The effect can vary from person to person. It works best for me when the colors are placed on a black background.
I didn't realise this was a thing. I see the 3D when I view these kind of images (usually some bright blue background) on my phone. I always wondered if it was some kind of optical trickery.