rotating background image with css for & lt; img & gt;


I tried to rotate image with -webkit-transform from jquery to rotate a background image for an <img> tag. which is actually rotating the src image. I tried :before to rotate background image in particular, still no luck.


<img class="customUpload" id="customUploads" style="height: 581px; background-image: url(; background-size: 80%; background-repeat: no-repeat no-repeat;" src="">

JS :



[Update] I just need to set the frame 90deg. Where as the inside HTML5 LOGO to rotate.

CSS transforms always apply to an element. If you want to rotate two things separately you need to create two elements:

<div id="frame"><img id="logo"></div></div>

Now you can use the CSS transform to rotate the #logo inside the #frame.

Demo on JSFiddle