Languages
[Edit]
EN

CSS - flip image vertically

0 points
Created by:
Violetd
925

In this article, we would like to show you how to flip image vertically using CSS.

Quick solution:

.flipped {
    transform: scaleY(-1);
}

or:

.flipped {
    transform: rotateX(180deg);
}

 

Practical examples

1. Using scaleY(-1)

In this example, we use transform CSS property with scaleY() function set to -1  to flip the image vertically and get the mirror image.

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<head>
  <style>

    .flipped {
        transform: scaleY(-1);
    }

  </style>
</head>
<body>
  <div>Original image:</div>
  <img src="https://dirask.com/static/bucket/1631898942509-VMYrnXyYZv--image.png" />
  <br>
  <div>transformed image</div>
  <img class="flipped" src="https://dirask.com/static/bucket/1631898942509-VMYrnXyYZv--image.png" />
</body>
</html>

2. Using rotateY(180deg)

In this solution, we rotate the image by an angle of 180 degrees using rotateY() function.

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<head>
  <style>

    .flipped {
        transform: rotateX(180deg);
    }

  </style>
</head>
<body>
  <div>Original image:</div>
  <img src="https://dirask.com/static/bucket/1631898942509-VMYrnXyYZv--image.png" />
  <br>
  <div>transformed image</div>
  <img class="flipped" src="https://dirask.com/static/bucket/1631898942509-VMYrnXyYZv--image.png" />
</body>
</html>

See also

  1. CSS - flip image horizontally

  2. CSS - flip image both vertically and horizontally

References

  1. transform - CSS: Cascading Style Sheets | MDN
  2. scaleY() - CSS: Cascading Style Sheets | MDN
  3. rotateX() - CSS: Cascading Style Sheets | MDN

Alternative titles

  1. CSS - rotate image 180 degrees x-axis
  2. CSS - get vertical mirror image (x-axis reflection)
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join