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

CSSWeb DevelopmentFront End Technology

Following is the code to flip and image using CSS −

Example

 Live Demo

<!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 −

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

raja
Published on 08-Apr-2020 07:58:21
Advertisements