I’m trying to get a background image to rotate when I hover over it. But at the same time I want some link text over top of the picture to NOT rotate.
I have it semi working, but when the image rotates the text get’s hidden behind it. and sometimes you will hover over the link, and the image doesn’t rotate. Is there a way to accomplish this?
JS Fiddle: http://bit.ly/1b9bpiJ
Dev Site: http://briggs.honeycombsites.com/
A slight modification to the excellent answer of Zeaklous.
To avoid the counter-rotation of the text, do not rotate the base div. Place the background in a pseudo element and rotate this.
updated demo
In the above answer, I forgot the unprefied transform in the after
Also, for some reason, the design breaks in firefox and IE; the font of the span needs to be set a little bit higher:
edited demo
I understand why you set up your code this way, but
transform
has some interesting unintentional effects at times. In your case it’s affecting the z-index somehow and I’m not sure exactly how to fix itWith that being said, here’s how I’d do it, which is simpler to me. It involves putting the text inside the rotating element, but rotating the text in the opposite direction at the same time in order to keep it upright
Demo here
Let me know if you have any questions about my method