Web Design Blog, Web Resources, Design Inspiration, Freebies, Tutorials

How to Apply CSS3 Transformations to Background Images

Scaling, skewing and rotating any element is possible with the CSS3 transform property. It’s supported in all modern browsers (with vendor prefixes) and degrades gracefully, e.g.

Great stuff. However, this rotates the whole element — it’s content, border and background image. What if you only want to rotate the background image? Or what if you want the background to remain fixed while the element is rotated?

Currently, there’s no W3C proposal for background-image transformations. It would be incredibly useful so I suspect one will appear eventually, but that doesn’t help developers who want to use similar effects today.

Fortunately, there is a solution. In essence, it’s a hack which applies the background image to a before or after pseudo element rather than the parent container. The pseudo element can then be transformed independently…

About the author

News from our community

Via: Source

If you would like to receive more inspiration from us, please consider subscribing to our feed by RSS and keep track of our tweets is simply to follow us on Twitter.

Leave a Response

You must be logged in to post a comment.
Share
Follow My Twitter Subcribe Full RSS