How to rotate + flip element with CSS

chinabuffet picture chinabuffet · Jun 10, 2013 · Viewed 50.9k times · Source

The transform property lets you rotate or flip, but how can you do both at the same time? Say I want to rotate an element 90 degrees and flip it horizontally? Both are done with the same property, so the latter overwrites the former. Here's an example fiddle for convenience:

http://jsfiddle.net/DtNh6/

transform: rotate(90deg);
transform: scaleX(-1);

Answer

James Green picture James Green · Jun 10, 2013

I fiddled with jsfiddle, and this worked:

$('#photo').css('transform', 'rotate(90deg) scaleX(-1)');

To relate it to your question, the resulting CSS looks like

transform: rotate(90deg) scaleX(-1);