Flipping Image can be extremely valuable these days. The most basic use-case for flipping images that I can consider would incorporate some sort of image on the front, and some data related to it on its back.
By using below code we can use this flipping effect in our application.
<div class="main-container" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="front-part">
<img src="images/blog1.png">
</div>
<div class="back-part">
<h1> DEMO</h1>
<p>Hello. I am an inventor.
I live in a small town somewhere in the world.
I am passionated about minimalistic and flat design.
</p>
</div>
</div>
</div>
There are two div front and back in above code, front div contain image part and back div contain some information,additionally it also have two containing components which have certain roles.
In above html code ontouchstart allow us to flip image when we put our cursor on it.
Below is the css for above code put it in your css file and include it into your html document.
.main-container {
perspective: 1000;
margin-left: 25%;
margin-top: 5%
}
.main-container:hover .flipper, .flip-container.hover .flipper {
transform:rotateY(180deg);
-ms-transform: rotateY(180deg); /* IE 9 */
-webkit-transform: rotateY(180deg); /* Chrome, Safari, Opera */
}
.flip-container, .front-part, .back-part {
width: 320px;
height: 480px;
}
.flipper {
transition: 0.6s;
transform-style: preserve-3d;
-webkit-transform-style: preserve-3d; /* Chrome, Safari, Opera */
position: relative;
}
.front-part, .back-part {
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
.front-part {
z-index: 2;
transform:rotateY(0deg);
-ms-transform: rotateY(0deg); /* IE 9 */
-webkit-transform: rotateY(0deg); /* Chrome, Safari, Opera */
}
.back-part {
transform:rotateY(180deg);
-ms-transform: rotateY(180deg); /* IE 9 */
-webkit-transform: rotateY(180deg); /* Chrome, Safari, Opera */
color: red;
}
0 Comment(s)