How to Flip the image and text on mouse over using HTML and CSS
Image Flip on Mouse over
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: Arial, Helvetica, sans-serif;
}
.flip-box {
background-color: transparent;
width: 300px;
height: 200px;
border: 1px solid #f1f1f1;
perspective: 1000px;
}
.flip-box-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: revert;
transform-style: unset;
}
.flip-box:hover .flip-box-inner {
transform: rotateY(180deg);
}
.flip-box-front {
background-color: rgb(230, 241, 67);
color: black;
}
</style>
</head>
<body>
<h1>Image Flip </h1>
<h3>Hover over the image to see the mirror effect:</h3>
<div class="flip-box">
<div class="flip-box-inner">
<div class="flip-box-front">
<img src="images/work-space.jpeg" alt="work-space" style="width:300px;height:200px">
</div>
</div>
</div>
</body>
</html>
Image Flip with Text on Mouse over
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: Arial, Helvetica, sans-serif;
}
.flip-box {
background-color: transparent;
width: 300px;
height: 200px;
border: 1px solid #ee9393ea;
perspective: 1000px;
}
.flip-box-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.8s;
transform-style: preserve-3d;
}
.flip-box:hover .flip-box-inner {
transform: rotateY(180deg);
}
.flip-box-front, .flip-box-back {
position: absolute;
width: 100%;
height: 100%;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.flip-box-front {
background-color: #bbb;
color: black;
}
.flip-box-back {
background-color: rgb(236, 240, 38);
color: rgb(3, 139, 82);
transform: rotateY(180deg);
}
</style>
</head>
<body>
<h1>Image Flip with Text</h1>
<h3>Hover over the image to see the effect :</h3>
<div class="flip-box">
<div class="flip-box-inner">
<div class="flip-box-front">
<img src="images/work-space.jpeg" alt="work-space" style="width:300px;height:200px">
</div>
<div class="flip-box-back">
<h2>work-space</h2>
<p>Office space available for all</p>
</div>
</div>
</div>
</body>
</html>
Keywords: