Computer >> Computer tutorials >  >> Programming >> CSS

How to flip an image (add a mirror effect) with CSS?


Following is the code to flip and image using CSS −

Example

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
img:hover {
   transform: scaleX(-1);
   width: 400;
   height: 400;
}
</style>
</head>
<body>
<h1>Flipping an Image Example</h1>
<img src="https://i.picsum.photos/id/551/400/400.jpg">
<h1>Hover over the above image to see it mirrored</h1>
</body>
</html>

Output

The above code will produce the following output −

How to flip an image (add a mirror effect) with CSS?

On hovering the image the image will be mirrored as follows −

How to flip an image (add a mirror effect) with CSS?