I am trying to create a flip animation for some images, which when they turn over, display appropriate link text. This works perfectly in all browsers that I have tested, but IE11.
I read that there is a problem with transform-style: preserve-3d; for IE10, but as I am a CSS beginner, I have been unable to figure out a way to correct the coding.
Here is the HTML:
<div class="flipcontainer">
<div class="flipscene3D">
<div class="flip">
<div>
<p>
<a itemprop="url" href="ARC3RFC.html"><span itemprop="headline">ARC3RFC Essay: Tomb 100, Tomb U-J and Maadi South: Themes from Predynastic Egypt</span></a> - 2013
</p>
</div>
<div>
<img src="ARC3RFC.jpg" class="flipimg">
</div>
</div>
</div>
</div>
And the CSS:
img.flipimg {
height: 150px;
width: 150px;
/*border-radius*/
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.flipcontainer {
display: block;
width: 760px;
height: 700px;
margin: 30px auto;
}
.flipscene3D {
display: block;
float: left;
margin: 10px;
/*border-radius*/
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
/*perspective*/
-webkit-perspective: 300px;
-moz-perspective: 300px;
-ms-perspective: 300px;
-o-perspective: 300px;
perspective: 300px;
}
.flip div {
position: absolute;
width: 150px;
height: 150px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
-o-backface-visibility: hidden;
backface-visibility: hidden;
z-index: 500
}
.flip div:first-child {
font-size: 12px;
/*border-radius*/
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
background: #333;
/*transform*/
-webkit-transform: rotateX(180deg);
-moz-transform: rotateX(180deg);
-ms-transform: rotateX(180deg);
-o-transform: rotateX(180deg);
transform: rotateX(180deg);
}
.flip div:first-child p {
color: #FFF;
text-shadow: 0 0 1px .111;
padding-top: 10px;
text-align: center;
}
.flip {
width: 150px;
height: 150px;
/*border-radius*/
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
/*box-shadow*/
-webkit-box-shadow: 0 0 15px rgba(0,0,0,0.3);
-moz-box-shadow: 0 0 15px rgba(0,0,0,0.3);
box-shadow: 0 0 15px rgba(0,0,0,0.3);
/*transform*/
-webkit-transform: rotateX(0deg);
-moz-transform: rotateX(0deg);
-ms-transform: rotateX(0deg);
-o-transform: rotateX(0deg);
transform: rotateX(0deg);
/*transition*/
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
/*transform-style*/
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
-o-transform-style: preserve-3d;
transform-style: preserve-3d;
}
.flipscene3D:hover .flip {
/*transform*/
-webkit-transform: rotateX(180deg);
-moz-transform: rotateX(180deg);
-ms-transform: rotateX(180deg);
-o-transform: rotateX(180deg);
transform: rotateX(180deg);
}
Have a look at this Flipping animation Demo. I hope it will solve your problem.
Check the DEMO.
Here is the HTML code look like.
<div class="wrapper">
<div class="front anim">
Chrome
</div>
<div class="back anim">
IE
</div>
</div>
Here is the CSS code.
.wrapper {
width: 300px;
height: 300px;
margin: auto;
position: relative;
}
.anim {
width: 100%;
height: 100%;
-o-transition: all .5s;
-ms-transition: all .5s;
-moz-transition: all .5s;
-webkit-transition: all .5s;
transition: all .5s;
-webkit-backface-visibility: hidden;
-ms-backface-visibility: hidden;
-moz-backface-visibility: hidden;
backface-visibility: hidden;
position: absolute;
top: 0px;
left: 0px;
}
.front {
z-index: 2;
background: url(http://lorempixel.com/300/300/) no-repeat;
}
.back {
z-index: 1;
-webkit-transform: rotateX(-180deg);
-ms-transform: rotateX(-180deg);
-moz-transform: rotateX(-180deg);
transform: rotateX(-180deg);
background: url(http://placehold.it/300x300) no-repeat;
}
.wrapper:hover .front {
z-index: 1;
-webkit-transform: rotateX(180deg);
-ms-transform: rotateX(180deg);
-moz-transform: rotateX(180deg);
transform: rotateX(180deg);
}
.wrapper:hover .back {
z-index: 2;
-webkit-transform: rotateX(0deg);
-ms-transform: rotateX(0deg);
-moz-transform: rotateX(0deg);
transform: rotateX(0deg);
}
.flipscene3D:hover .flip {
/*transform*/
-webkit-transform: rotateX(180deg);
-moz-transform: rotateX(180deg);
-ms-transform: rotateX(180deg);
-o-transform: rotateX(180deg);
transform: rotateX(180deg);
filter: progid:DXImageTransform.Microsoft.Matrix(M11=-1,
M12=1.2246467991473532e-16,
M21=-1.2246467991473532e-16,
M22=-1,
SizingMethod='auto expand');
}
Related
.featured_widgets {
margin: 4% 0px;
}
.featured_widgets .columns {
display: table;
margin-bottom: 20px;
text-align: center;
}
.featured_widgets .widget_box {
height: 156px;
text-align: center;
margin: 0px 1%;
vertical-align: middle;
width: 100%;
display: table-cell;
padding: 0px 20px;
}
.featured_widgets .widget_box .front img {
height: 120px;
}
.featured_widgets .widget_box .front {
height: 140px;
}
.featured_widgets .widget_box .back {
height: 140px;
padding-top: 40px;
color: #fff;
font-size: 17px;
}
.featured_widgets .columns .title {
display: table-row;
}
.featured_widgets .columns .title h5 {
color: #999;
padding: 0px 15px;
font-size: 15px;
}
.flip-container {
transform: perspective(1000px);
transform-style: preserve-3d;
}
.flip-container:hover .back,
.flip-container.hover .back {
transform: rotateY(0deg);
}
.flip-container:hover .front,
.flip-container.hover .front {
transform: rotateY(180deg);
}
.flipper {
perspective: 800px;
perspective-origin: 50% 100px;
position: relative;
transform: perspective(1000px);
transform-style: preserve-3d;
transition: all 0.6s ease 0s;
}
.front,
.back {
backface-visibility: hidden;
position: relative;
transform: rotateY(0deg);
transform-style: preserve-3d;
transition: all 1s ease 0.3s;
}
.front {
z-index: 2;
}
.back {
margin-top: -180px;
text-align: center;
transform: rotateY(-180deg);
}
.vertical.flip-container {
position: relative;
}
.vertical .back {
transform: rotateX(180deg);
}
.vertical.flip-container .flipper {
transform-origin: 100% 213.5px 0;
}
.vertical.flip-container:hover .back,
.vertical.flip-container.hover .back {
transform: rotateX(0deg);
}
.vertical.flip-container:hover .front,
.vertical.flip-container.hover .front {
transform: rotateX(180deg);
}
.seagreen_bg {
background: #1cbec9;
}
.inxblue_bg {
background: #0075ba;
}
.inxorange_bg {
background: #f37b20;
}
.inxyellow_bg {
background: #fdb813;
}
.btn_line {
border: 1px solid #fff;
border-radius: 5px;
display: inline-block;
font-size: 14px;
font-weight: normal;
margin-top: 10px;
padding: 8px 15px;
color: #fff;
}
.btn_line:hover {
background: #333 none repeat scroll 0 0;
border: 1px solid #000;
color: #fff;
text-decoration: none;
}
<div class="container">
<div class="row featured_widgets">
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12 columns flip-container vertical">
<div class="widget_box flipper seagreen_bg">
<div class="front">
<img src="https://cdn.sparkfun.com/assets/9/9/2/5/e/51f9a101757b7f032ab7f724.png" alt="">
</div>
<div class="back">
<h5>text text text text text text.</h5>
<h5><a class="btn_line" href="#">Learn More ›</a></h5>
</div>
</div>
<div class="title">
<h4>text</h4>
<h5>text text text text text text.</h5>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12 columns flip-container vertical">
<div class="widget_box flipper inxblue_bg">
<div class="front">
<img src="https://cdn.sparkfun.com/assets/9/9/2/5/e/51f9a101757b7f032ab7f724.png" alt="">
</div>
<div class="back">
<h5>text text text text text text.</h5>
<h5><a class="btn_line" href="#">Learn More ›</a></h5>
</div>
</div>
<div class="title">
<h4>text</h4>
<h5>text text text text text text.</h5>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12 columns flip-container vertical">
<div class="widget_box flipper inxorange_bg">
<div class="front">
<img src="https://cdn.sparkfun.com/assets/9/9/2/5/e/51f9a101757b7f032ab7f724.png" alt="">
</div>
<div class="back">
<h5>text text text text text text.</h5>
<h5><a class="btn_line" href="#">Learn More ›</a></h5>
</div>
</div>
<div class="title">
<h4>text</h4>
<h5>text text text text text text</h5>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12 columns flip-container vertical">
<div class="widget_box flipper inxyellow_bg">
<div class="front">
<img src="https://cdn.sparkfun.com/assets/9/9/2/5/e/51f9a101757b7f032ab7f724.png" alt="">
</div>
<div class="back">
<h5>text text text text text text.</h5>
<h5><a class="btn_line" href="">Learn More ›</a></h>
</div>
</div>
<div class="title">
<h4>text</h4>
<h5>text</h5>
</div>
</div>
</div>
</div>
You need the -webkit- prefix to make it work in safari:
-webkit-transform: rotateY(180deg);
See compatibility table:
http://caniuse.com/#search=transform
Try This-
.featured_widgets {
margin: 4% 0px;
}
.featured_widgets .columns {
display: table;
margin-bottom: 20px;
text-align: center;
}
.featured_widgets .widget_box {
height: 156px;
text-align: center;
margin: 0px 1%;
vertical-align: middle;
width: 100%;
display: table-cell;
padding: 0px 20px;
}
.featured_widgets .widget_box .front img {
height: 120px;
}
.featured_widgets .widget_box .front {
height: 140px;
}
.featured_widgets .widget_box .back {
height: 140px;
padding-top: 40px;
color: #fff;
font-size: 17px;
}
.featured_widgets .columns .title {
display: table-row;
}
.featured_widgets .columns .title h5 {
color: #999;
padding: 0px 15px;
font-size: 15px;
}
.flip-container {
transform:perspective(1000px);
-moz-transform:perspective(1000px);
-ms-transform:perspective(1000px);
-o-transform:perspective(1000px);
-webkit-transform:perspective(1000px);
transform-style:preserve-3d;
}
.flip-container:hover .back ,
.flip-container.hover .back {
transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
-o-transform: rotateY(0deg);
-webkit-transform: rotateY(0deg);
}
.flip-container:hover .front ,
.flip-container.hover .front {
transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
}
.flipper {
perspective: 800px;
perspective-origin: 50% 100px;
position: relative;
transform: perspective(1000px);
-moz-transform: perspective(1000px);
-ms-transform: perspective(1000px);
-o-transform: perspective(1000px);
-webkit-transform: perspective(1000px);
transform-style: preserve-3d;
transition: all 0.6s ease 0s;
-moz-transition: all 0.6s ease 0s;
-ms-transition: all 0.6s ease 0s;
-o-transition: all 0.6s ease 0s;
-webkit-transition: all 0.6s ease 0s;
}
.front {
backface-visibility: hidden;
position: relative;
transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
-o-transform: rotateY(0deg);
-webkit-transform: rotateY(0deg);
transform-style: preserve-3d;
transition: all 1s ease 0.3s;
-moz-transition: all 1s ease 0.3s;
-ms-transition: all 1s ease 0.3s;
-o-transition: all 1s ease 0.3s;
-webkit-transition: all 1s ease 0.3s;
z-index: 2;
}
.back {
backface-visibility: hidden;
position: relative;
transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
-o-transform: rotateY(0deg);
-webkit-transform: rotateY(0deg);
transform-style: preserve-3d;
transition: all 1s ease 0.3s;
-moz-transition: all 1s ease 0.3s;
-ms-transition: all 1s ease 0.3s;
-o-transition: all 1s ease 0.3s;
-webkit-transition: all 1s ease 0.3s;
}
.back {
margin-top: -180px;
text-align: center;
transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
-ms-transform: rotateY(-180deg);
-o-transform: rotateY(-180deg);
-webkit-transform: rotateY(-180deg);
}
.vertical.flip-container {
position: relative;
}
.vertical .back {
transform: rotateX(180deg);
-moz-transform: rotateX(180deg);
-ms-transform: rotateX(180deg);
-o-transform: rotateX(180deg);
-webkit-transform: rotateX(180deg);
}
.vertical.flip-container .flipper {
transform-origin: 100% 213.5px 0;
}
.vertical.flip-container:hover .back ,
.vertical.flip-container.hover .back {
transform: rotateX(0deg);
-moz-transform: rotateX(0deg);
-ms-transform: rotateX(0deg);
-o-transform: rotateX(0deg);
-webkit-transform: rotateX(0deg);
}
.vertical.flip-container:hover .front ,
.vertical.flip-container.hover .front {
transform: rotateX(180deg);
-moz-transform: rotateX(180deg);
-ms-transform: rotateX(180deg);
-o-transform: rotateX(180deg);
-webkit-transform: rotateX(180deg);
}
.seagreen_bg {
background: #1cbec9;
}
.inxblue_bg {
background: #0075ba;
}
.inxorange_bg {
background: #f37b20;
}
.inxyellow_bg {
background: #fdb813;
}
.btn_line {
border: 1px solid #fff;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
display: inline-block;
font-size: 14px;
font-weight: normal;
margin-top: 10px;
padding: 8px 15px;
color: #fff;
}
.btn_line:hover {
background: #333 none repeat scroll 0 0;
border: 1px solid #000;
color: #fff;
text-decoration: none;
}
I'm trying to code a way to rotate a div on mouse hover and show a different content than before.
An example can be seen here: www.possibile.com
And here is my code for what I'm trying to do:
#container {
width: 500px;
height: 500px;
margin: 0 auto;
}
.rotate {
width: 200px;
height: 200px;
margin: 150px;
background-color: red;
-webkit-transition: 1s ease-in;
-moz-transition: 1s ease-in;
-o-transition: 1s ease-in;
transition: 1s ease-in;
}
.rotate:hover {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.rotate:hover > p.front {
display: none;
}
p.rear {
display: none;
-webkit-transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
-o-transform: rotateY(-180deg);
-ms-transform: rotateY(-180deg);
transform: rotateY(-180deg);
}
.rotate:hover > p.rear {
display: block;
}
<div id="container">
<div class="rotate">
<p class="front">This is a div to rotate.</p>
<p class="rear">
This is the div rotated.
</p>
</div>
http://jsfiddle.net/wLLLsjLd/1/
The problem with my code is that whenever I hover upon the div, it shows the "rear" p at the beginning of the rotation and not in the end.
Any help?
You can check with the below link.
Fiddle
body {
background: #ecf0f1;
}
ul {
width: 50%;
margin: 120px auto;
}
li {
width: 200px;
height: 200px;
margin-right: 10px;
margin-bottom: 10px;
float: left;
list-style: none;
position: relative;
cursor: pointer;
font-family:'Open Sans';
font-weight: 300;
-webkit-perspective: 1000;
-moz-perspective: 1000;
perspective: 1000;
}
div {
color: yellow;
width: 100%;
height: 100%;
position: absolute;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
transition: all 0.5s ease;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
backface-visibility: hidden;
}
.front {
z-index: 3;
color: #fff;
text-align: center;
line-height: 210px;
font-size: 20px;
background: #e3e3e3;
}
li:hover > .front{
z-index: 0;
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
}
li:hover > .back {
-webkit-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
transform: rotateY(0deg);
}
.back {
color: #fff;
text-align: center;
line-height: 200px;
font-size: 22px;
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
background: #34495e;
}
#box1 {
background: red;
}
Im hoping someone can help me get my code to flip my second image properly (not mirror image) when viewed in IE. I think I have it working properly in the other browsers.
My goal is to have picture #1 show, then upon button click show the picture #2.
The code also uses javascript + jquery but my knowledge currently is limited.
Can someone offer a solution via css that I can add or amend my code with to accomplish what I am trying to do? Thanks.
My fiddle: http://jsfiddle.net/zgn9kd0L/6/
HTML
<div id="block" class="block" onclick="changeClass()">
<div class="front side">
<img src="http://imgur.com/etY8veW.jpg" alt="" />
</div>
<div class="back side">
<img src="http://imgur.com/DiSXWpR.jpg" alt="" />
</div>
</div>
<button class="flip">Flip</button>
CSS
#container {
height: 500px;
width: 500px;
position: relative;
/*perspective*/
-webkit-perspective: 500;
-moz-perspective: 500;
-ms-perspective: 500;
-o-perspective: 500;
perspective: 500;
}
.block {
position: relative;
height: 500px;
width: 500px;
/*transform-style*/
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
-o-transform-style: preserve-3d;
transform-style: preserve-3d;
/*transition*/
-webkit-transition: -webkit-transform 1.5s;
-moz-transition: -moz-transform 1.5s;
-o-transition: -o-transform 1.5s;
transition: transform 1.5s;
}
.rotated {
/*transform*/
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.side {
position: absolute;
/*backface-visibility*/
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
-o-backface-visibility: hidden;
backface-visibility: hidden;
}
.front {
}
.back {
/*transform*/
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.flip {
background: white;
font-family: 'open sans';
font-weight: 400;
color: #5b5b5b;
border-radius: 5px;
margin-top: 1em;
}
IE10+ only has partial support for the property transform-style: preserve-3d. I assume that's why it wasn't working.
Here is a similar alternative that works in IE. (updated example)
HTML
<div class="block">
<div class="front side">
<img src="http://imgur.com/etY8veW.jpg" alt="" />
</div>
<div class="back side">
<img src="http://imgur.com/DiSXWpR.jpg" alt="" />
</div>
</div>
CSS - vendor prefixes omitted. See the example.
.block {
width: 500px;
height: 500px;
position: relative;
perspective: 500;
}
.side {
position: absolute;
transition: transform 0.5s;
backface-visibility: hidden;
}
.side.rotated {
transform: rotateY(360deg);
}
.back {
transform: rotateY(180deg);
}
If you are looking for Pure CSS Solutions here are few:
Create a CSS Flipping Animation
Working Demo
HTML:
<div class="flip-container" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="front">
<span class="name">David Walsh</span>
</div>
<div class="back">
<div class="back-logo"></div>
<div class="back-title">#davidwalshblog</div>
<p>Mozilla Web Developer, MooTools & jQuery Consultant, MooTools Core Developer, Javascript Fanatic, CSS Tinkerer, PHP Hacker, and web lover.</p>
</div>
</div>
</div>
CSS:
.flip-container {
-webkit-perspective: 1000;
-moz-perspective: 1000;
-o-perspective: 1000;
perspective: 1000;
border: 1px solid #ccc;
}
.flip-container:hover .flipper,
.flip-container.hover .flipper {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.flip-container, .front, .back {
width: 320px;
height: 427px;
}
.flipper {
-webkit-transition: 0.6s;
-webkit-transform-style: preserve-3d;
-moz-transition: 0.6s;
-moz-transform-style: preserve-3d;
-o-transition: 0.6s;
-o-transform-style: preserve-3d;
transition: 0.6s;
transform-style: preserve-3d;
position: relative;
}
.front, .back {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-o-backface-visibility: hidden;
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
.front {
background: url(http://davidwalsh.name/demo/dwflip.jpg) 0 0 no-repeat;
z-index: 2;
}
.back {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
background: #f8f8f8;
}
.front .name {
font-size: 2em;
display: inline-block;
background: rgba(33, 33, 33, 0.9);
color: #f8f8f8;
font-family: Courier;
padding: 5px 10px;
border-radius: 5px;
bottom: 60px;
left: 25%;
position: absolute;
text-shadow: 0.1em 0.1em 0.05em #333;
-webkit-transform: rotate(-20deg);
-moz-transform: rotate(-20deg);
-o-transform: rotate(-20deg);
transform: rotate(-20deg);
}
.back-logo {
position: absolute;
top: 40px;
left: 90px;
width: 160px;
height: 117px;
background: url(http://davidwalsh.name/demo/logo.png) 0 0 no-repeat;
}
.back-title {
font-weight: bold;
color: #00304a;
position: absolute;
top: 180px;
left: 0;
right: 0;
text-align: center;
text-shadow: 0.1em 0.1em 0.05em #acd7e5;
font-family: Courier;
font-size: 2em;
}
.back p {
position: absolute;
bottom: 40px;
left: 0;
right: 0;
text-align: center;
padding: 0 20px;
font-family: arial;
line-height: 2em;
}
I found this tutorial on how to CSS flip a div. You can find the result here. now the thing is, i want to keep the puzzle piece flipped to the back after the hover so the information on the back remains visible. Now i'm not very strong in working with css3. So any help on realizing the desired would be very appreciated!
Here is the code i'm using:
html:
<div class="flip-container" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="puzzel-stuk">
<div class="front" style="background:url('img/puzzel-links-boven-gesloten.png'); background-repeat:no-repeat; width: 323px; height: 429px;"></div>
<div class="back" style="background:url('img/puzzel-links-boven-open.png'); background-repeat:no-repeat; width: 323px; height: 429px; text-align:left;">
<div class="stap-title">
<h1>Stap 1</h1>
</div>
<div class="stap-tekst" style="margin-left:10px;">
Kies een geschikte achtergrond,<br/>
zodat uw brief meer opvalt<br/>
bij uw potentiële werkgever.
</div>
</div>
</div>
</div>
</div>
css:
/* simple */
.flip-container {
-webkit-perspective: 1000;
-moz-perspective: 1000;
-ms-perspective: 1000;
perspective: 1000;
-ms-transform: perspective(1000px);
-moz-transform: perspective(1000px);
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
}
/*
.flip-container:hover .flipper, .flip-container.hover .flipper, #flip-toggle.flip .flipper {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
transform: rotateY(180deg);
filter: FlipH;
-ms-filter: "FlipH";
}
*/
/* START: Accommodating for IE */
.flip-container:hover .back, .flip-container.hover .back {
-webkit-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
-o-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
transform: rotateY(0deg);
}
.flip-container:hover .front, .flip-container.hover .front {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
/* END: Accommodating for IE */
.flip-container, .front, .back {
width: 320px;
height: 427px;
font-size:18px;
display:inline-block;
float:left;
}
.flipper {
-webkit-transition: 0.6s;
-webkit-transform-style: preserve-3d;
-ms-transition: 0.6s;
-moz-transition: 0.6s;
-moz-transform: perspective(1000px);
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
transition: 0.6s;
transform-style: preserve-3d;
position: relative;
}
.front, .back {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-transition: 0.6s;
-webkit-transform-style: preserve-3d;
-moz-transition: 0.6s;
-moz-transform-style: preserve-3d;
-o-transition: 0.6s;
-o-transform-style: preserve-3d;
-ms-transition: 0.6s;
-ms-transform-style: preserve-3d;
transition: 0.6s;
transform-style: preserve-3d;
position: absolute;
top: 0;
left: 0;
}
.front {
-webkit-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
background: lightgreen;
z-index: 2;
}
.back {
background: lightblue;
-webkit-transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
-o-transform: rotateY(-180deg);
-ms-transform: rotateY(-180deg);
transform: rotateY(-180deg);
}
.front .name {
font-size: 2em;
display: inline-block;
background: rgba(33, 33, 33, 0.9);
color: #f8f8f8;
font-family: Courier;
padding: 5px 10px;
border-radius: 5px;
bottom: 60px;
left: 25%;
position: absolute;
text-shadow: 0.1em 0.1em 0.05em #333;
display: none;
-webkit-transform: rotate(-20deg);
-moz-transform: rotate(-20deg);
-ms-transform: rotate(-20deg);
transform: rotate(-20deg);
}
.back-logo {
position: absolute;
top: 40px;
left: 90px;
width: 160px;
height: 117px;
background: url(logo.png) 0 0 no-repeat;
}
.back-title {
font-weight: bold;
color: #00304a;
position: absolute;
top: 180px;
left: 0;
right: 0;
text-align: center;
text-shadow: 0.1em 0.1em 0.05em #acd7e5;
font-family: Courier;
font-size: 2em;
}
.back p {
position: absolute;
bottom: 40px;
left: 0;
right: 0;
text-align: center;
padding: 0 20px;
}
/* vertical */
.vertical.flip-container {
position: relative;
}
.vertical .back {
-webkit-transform: rotateX(180deg);
-moz-transform: rotateX(180deg);
-ms-transform: rotateX(180deg);
transform: rotateX(180deg);
}
.vertical.flip-container .flipper {
-webkit-transform-origin: 100% 213.5px;
-moz-transform-origin: 100% 213.5px;
-ms-transform-origin: 100% 213.5px;
transform-origin: 100% 213.5px;
}
/*
.vertical.flip-container:hover .flipper {
-webkit-transform: rotateX(-180deg);
-moz-transform: rotateX(-180deg);
-ms-transform: rotateX(-180deg);
transform: rotateX(-180deg);
}
*/
/* START: Accommodating for IE */
.vertical.flip-container:hover .back, .vertical.flip-container.hover .back {
-webkit-transform: rotateX(0deg);
-moz-transform: rotateX(0deg);
-o-transform: rotateX(0deg);
-ms-transform: rotateX(0deg);
transform: rotateX(0deg);
}
.vertical.flip-container:hover .front, .vertical.flip-container.hover .front {
-webkit-transform: rotateX(180deg);
-moz-transform: rotateX(180deg);
-o-transform: rotateX(180deg);
transform: rotateX(180deg);
}
/* END: Accommodating for IE */
.stap-title {
width:40%;
margin:0 auto;
margin-top:10px;
display:block;
position:relative;
}
.stap-tekst {
margin-left:10px;
margin-right:10px;
margin-top:20px;
display:block;
width:auto;
position:relative;
}
Add the following jquery code in your file.
$(document).ready(function(){
$('.flip-container').hover(function(){
$(this).addClass('hoverfixed');
});
});
Add the following two Classes in your CSS.
.hoverfixed .back{
-webkit-transform: rotateY(0deg) !important;
-moz-transform: rotateY(0deg) !important;
-o-transform: rotateY(0deg) !important;
-ms-transform: rotateY(0deg) !important;
transform: rotateY(0deg) !important;
}
.hoverfixed .front{
-webkit-transform: rotateY(180deg) !important;
-moz-transform: rotateY(180deg) !important;
-o-transform: rotateY(180deg) !important;
transform: rotateY(180deg) !important;
}
I am using the following CSS to make a flipping transition with CSS3:
/* simple */
.flip-container {
-webkit-perspective: 1000;
-moz-perspective: 1000;
perspective: 1000;
-webkit-box-shadow: 1px 1px 1px 1px #ccc;
-moz-box-shadow: 1px 1px 1px 1px #ccc;
box-shadow: 1px 1px 1px 1px #ccc;
border: 1px solid #fff;
}
.flip-container:hover .flipper, .flip-container.hover .flipper {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.flip-container, .front, .back {
width: 160px;
height: 160px;
}
.flipper {
-webkit-transition: 0.6s;
-webkit-transform-style: preserve-3d;
-moz-transition: 0.6s;
-moz-transform-style: preserve-3d;
transition: 0.6s;
transform-style: preserve-3d;
position: relative;
}
.front, .back {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
.front {
z-index: 2;
text-align: center;
}
.back {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.front .name {
font-size: 2em;
display: inline-block;
background: rgba(33, 33, 33, 0.9);
color: #f8f8f8;
font-family: Courier;
padding: 5px 10px;
border-radius: 5px;
bottom: 60px;
left: 25%;
position: absolute;
text-shadow: 0.1em 0.1em 0.05em #333;
-webkit-transform: rotate(-20deg);
-moz-transform: rotate(-20deg);
transform: rotate(-20deg);
}
.back-logo {
position: absolute;
top: 40px;
left: 90px;
width: 160px;
height: 117px;
background: url(logo.png) 0 0 no-repeat;
}
.back-title {
font-weight: bold;
color: #00304a;
position: absolute;
top: 180px;
left: 0;
right: 0;
text-align: center;
text-shadow: 0.1em 0.1em 0.05em #acd7e5;
font-family: Courier;
font-size: 2em;
}
.back p {
position: absolute;
bottom: 40px;
left: 0;
right: 0;
text-align: center;
padding: 0 20px;
}
Implementation of the CSS is as follows:
<div class="sidepanel" id="troll">
<div class="flip-container" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<a href="../articlenew/troll.php?id=<?php echo rand(1,$maxnum);?>"><div class="front" >
<span style="font-size: 26px; color:#333;">The Best Thing in this World is</span><br />
<strong style="font-size: 40px; color:red;">SE...</strong></div></a>
<a href="../articlenew/troll.php?id=<?php echo rand(1,$maxnum);?>"><div class="back" style="text-align:center; color:#333;">
<!-- back content -->
<span style="font-size: 30px">Secrets!</span>
<img src="../trial/youmad.png" width="70" height="70" /><br />
<span style="font-size: 20px">You Mad?</span><br />
<span style="font-size: 16px">Best College Trolls</span> </div></a>
</div>
</div>
THe problem is that in some browsers it works fine, in some, i see the front text as well as the back text reversed, like when one sees a text in mirror. I have no clue where its messing up. I did gave browser version and compatibility a thought but i think HTML5 and CSS3 are enough popular now and all browsers support them. I am also sharing some images to explain:
Use this code it will solve your problem
css
.flip-container {
-webkit-perspective: 1000;
-moz-perspective: 1000;
-o-perspective:1000;
-ms-perspective: 1000;
perspective: 1000;
-ms-transform: perspective(1000px);
-moz-transform: perspective(1000px);
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
}
/* for IE */
.flip-container:hover .back, .flip-container.hover .back {
-webkit-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
-o-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
transform: rotateY(0deg);
}
.flip-container:hover .front, .flip-container.hover .front {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
/* END: for IE */
.flipper {
-webkit-transition: 0.6s;
-webkit-transform-style: preserve-3d;
-ms-transition: 0.6s;
-moz-transition: 0.6s;
-moz-transform: perspective(1000px);
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
transition: 0.6s;
transform-style: preserve-3d;
position: relative;
top: 0;
left: 0;
width: 180px;
height: 180px;
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
}
.front, .back {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-transition: 0.6s;
-webkit-transform-style: preserve-3d;
-moz-transition: 0.6s;
-moz-transform-style: preserve-3d;
-o-transition: 0.6s;
-o-transform-style: preserve-3d;
-ms-transition: 0.6s;
-ms-transform-style: preserve-3d;
transition: 0.6s;
transform-style: preserve-3d;
position: absolute;
top: 0;
left: 0;
width: 180px;
height: 180px;
}
.front {
-webkit-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
background-position: center center;
z-index: 2;
background:green;
}
.back {
background: #f2f2f2;
-webkit-transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
-o-transform: rotateY(-180deg);
-ms-transform: rotateY(180deg);
transform: rotateY(-180deg);
}
Demo on Jsfiddle
I.E doesn't support backface-visibility
About Chrome, check here
I would also try setting backface-visibility hidden and transform-style : preserve-3d to everything (just to check)