A Web Design Community curated by Chris Coyier

Code Snippets Gallery

Code Snippets > CSS > Flip an Image Submit one!

Flip an Image

You can flip images with CSS! Possible scenario: having only one graphic for an “arrow”, but flipping it around to point in different directions.

img {
        -moz-transform: scaleX(-1);
        -o-transform: scaleX(-1);
        -webkit-transform: scaleX(-1);
        transform: scaleX(-1);
        filter: FlipH;
        -ms-filter: "FlipH";
}

Demo

Unflipped

Flipped

13 Responses

  1. Can this be applied to background-images? If so, it’d be perfect for stuff like buttons and shadowed boxes.

  2. If you would apply this on a sprite image, would you need to reverse the coordinates as wel?

  3. It cannot be applied to background images. Only elements.

  4. Brian Lang says:

    When viewed in RSS reader, the flipped image is not flipped :)

  5. Bert de Vries says:

    How about using this for a reflection? Flip an image vertically and reduce the opacity? Possible?

  6. Rick says:

    Too bad you don’t give Gijs Stegehuis the credits it..

  7. Gijs Stegehuis says:

    I needed ‘image-rendering: -moz-crisp-edges;’ for this to work properly with a gif arrow in Firefox on OSX. Without this property it was rendered very blurry.

  8. Andrew says:

    Perfect – finally – excellent! Is this a CSS3-only property? What is the cross-browser compatibility of this?

Leave a Comment

Remember:
  • Be nice.
  • Wrap multiline code in <pre> and <code> tags and escape it first (turn <'s into &lt;'s).
  • You may use regular HTML stuff like <a href="">, <em>, and <strong>
* This website may or may not contain any actual CSS or Tricks.