How to show different content when rotating a div - html

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;
}

Related

Adjusting text in html/css portfolio website project

I am attemping to move title "data analyst" to be centered in this piece of code.. I'm not sure why it's not already as code is labeled center in the .front-person-titles > span piece of css. I am very new to css/html (just started working on this portfolio webpage a few days ago.) Where in these lines of css would I change the code so that data analayst text is centered?? In addition to this, when I run code snippet in stackoverflow, the image is formatted the same as the gray box from .front-person-img css code and NOT from the .front-person-img > img code. I am not sure how to make the image respond to the > img code so that its formatting is separate as seen in this jpeg.
Thank you!
.front-section {
padding-top: 60px;
padding-bottom: 200px;
position: relative;
}
}
.section-block>.container,
.section-block {
position: relative;
}
/*=======================================================================
Front Section
=======================================================================*/
body.section-show .transition-mask {
position: absolute;
top: 260px;
height: 500px;
width: 500px;
left: 0;
right: 0;
margin: auto;
z-index: 22;
transform: rotate(45deg);
overflow: hidden;
-webkit-animation: fill2 .8s .4s both ease;
-moz-animation: fill2 .8s .4s both ease;
animation: fill2 .8s .4s both ease;
}
body .transition-mask:before {
content: ' ';
position: absolute;
bottom: 0;
right: 0;
height: 100%;
width: 100%;
}
body.section-show .transition-mask:before {
-webkit-animation: fill .4s both ease;
-moz-animation: fill .4s both ease;
animation: fill .4s both ease;
background: #CCC;
}
#-webkit-keyframes fill2 {
0% {
transform: rotate(45deg);
}
100% {
z-index: 50;
transform: rotate(0deg);
height: 100%;
width: 100%;
top: 0;
bottom: auto;
}
}
#keyframes fill2 {
0% {
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
100% {
z-index: 50;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
height: 100%;
width: 100%;
top: 0;
bottom: auto;
}
}
#-webkit-keyframes fill {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#keyframes fill {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
.front-section {
padding-top: 60px;
padding-bottom: 200px;
position: relative;
}
.front-heading {
text-align: center;
margin-top: 190px;
}
.front-heading>h2 {
font-size: 55px;
font-weight: lighter;
letter-spacing: 15px;
position: relative;
position: relative;
line-height: 1em;
display: inline-block;
*display: inline;
*zoom: 1;
z-index: 10;
color: #999;
font-family: 'Playfair Display', serif;
font-style: italic;
}
.front-person-img {
width: 500px;
height: 500px;
overflow: hidden;
background: #F0F0F0;
position: relative;
z-index: 15;
-webkit-transition: height .5s .3s ease, transform .5s .8s ease;
-moz-transition: height .5s .3s ease, transform .5s .8s ease;
transition: height .5s .3s ease, transform .5s .8s ease;
margin: 200px auto;
margin-bottom: 0;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
border-radius: 0;
}
.front-person-img > img {
max-width: 100%;
left: -40px;
top: 40px;
position: relative;
vertical-align: bottom;
}
.front-person-titles {
position: relative;
z-index: 10;
height: 500px;
width: 500px;
margin: auto;
margin-top: -500px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
.front-person-titles>span {
position: absolute;
z-index: 5;
display: block;
width: 100%;
font-family: Hind, sans-serif;
color: #CCC;
text-align: center;
font-size: 24px;
letter-spacing: 25px;
line-height: 2em;
text-transform: lowercase;
}
.front-person-titles>.t1 {
right: 0;
bottom: 0;
-webkit-transform: rotate(-90deg) translateY(-100%);
-moz-transform: rotate(-90deg) translateY(-100%);
-ms-transform: rotate(-90deg) translateY(-100%);
-o-transform: rotate(-90deg) translateY(-100%);
transform: rotate(-90deg) translateY(-100%);
-webkit-transform-origin: 0% 0%;
-moz-transform-origin: 0% 0%;
-ms-transform-origin: 0% 0%;
-o-transform-origin: 0% 0%;
transform-origin: 0% 0%;
}
.front-person-titles>.t2 {
top: 0px;
left: 0;
-webkit-transform: translateY(-100%);
-moz-transform: translateY(-100%);
-ms-transform: translateY(-100%);
-o-transform: translateY(-100%);
transform: translateY(-100%);
}
.front-person-titles>.t3 {
left: 0;
bottom: 5px;
-webkit-transform: translateY(100%) rotate(180deg);
-moz-transform: translateY(100%) rotate(180deg);
-ms-transform: translateY(100%) rotate(180deg);
-o-transform: translateY(100%) rotate(180deg);
transform: translateY(100%) rotate(180deg);
}
.front-person-links {
margin: auto;
width: 500px;
height: 500px;
margin-top: -500px;
z-index: 25;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
position: relative;
}
.front-person-links>ul>li {
display: block;
}
.front-person-links>ul {
font-size: 0;
z-index: 99;
position: absolute;
text-align: left;
white-space: nowrap;
left: 100%;
top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
margin: 0;
padding: 0;
list-style: none;
margin-left: -15px;
}
.front-person-links>ul>li>a {
font-weight: bold;
display: block;
font-size: 14px;
padding: 25px 0;
cursor: pointer;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
transition: all .3s ease;
position: relative;
color: #999;
text-align: left;
text-transform: uppercase;
letter-spacing: 3px;
text-decoration: none;
line-height: 1em;
}
.front-person-links>ul>li>a:before,
.front-person-links>ul>li>a:after {
content: ' ';
height: 6px;
width: 15px;
background: #CCC;
display: inline-block;
*display: inline;
*zoom: 1;
vertical-align: middle;
margin-right: 15px;
font-size: 0;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
transition: all .3s ease;
display: none;
}
.front-person-links>ul>li>a:after {
margin-left: 15px;
margin-right: 0;
display: none;
}
.front-person-links>ul>li>a:hover {
color: #B7A389;
}
.front-person-links>ul>li>a:hover:after,
.front-person-links>ul>li>a:hover:before {
width: 25px;
background: #999;
}
<!--=============================================================================
Front Section
===============================================================================-->
<section class='front-section'>
<div class='container'>
<div class='transition-mask'></div>
<div class='front-person-img'>
<!--person's image-->
<img src="https://i.ibb.co/qY05xXH/IMG-5876.jpg" alt="IMG-5876" border="0">
<!--/person's image-->
</div>
<!--person's titles-->
<div class='front-person-titles'>
<!--title1-->
<span class='t1'>
Data Analyst
</span>
<!--/title1-->
<!--title2-->
<span class='t2'>
Student
</span>
<!--/title2-->
<!--title3-->
<span class='t3'>
</span>
<!--/title3-->
</div>
I was able to get it looking how you want by modifying the .front-person-titles>.t1 code to the following:
.front-person-titles>.t1 {
right: 0;
bottom: 0;
-webkit-transform: rotate(-90deg) translateY(-100%) translateX(-7.5%);
-moz-transform: rotate(-90deg) translateY(-100%) translateX(-7.5%);
-ms-transform: rotate(-90deg) translateY(-100%) translateX(-7.5%);
-o-transform: rotate(-90deg) translateY(-100%) translateX(-7.5%);
transform: rotate(-90deg) translateY(-100%) translateX(-7.5%);
-webkit-transform-origin: 0% 0%;
-moz-transform-origin: 0% 0%;
-ms-transform-origin: 0% 0%;
-o-transform-origin: 0% 0%;
transform-origin: 0% 0%;
}
You can see a working JSFiddle here.

Change hover to touch

I am trying to make this effect touch-friendly. I have a thumbnail gallery that has titles and descriptions. The title is displayed on load, and when the user hovers over the thumbnail they see the longer description. Then they can click on the entire image to go to the linked page.
I have tried several options, like this one but none seem to work. I'd be fine if the hover acted as a touch to display caption info, and a second touch will open the link that is assigned to the image. Right now, the first touch displays the description for a half second, then follows the link.
I'm open to CSS or js options- I just need to get something to work!
.caption {
position: relative;
overflow: hidden;
/* Only the -webkit- prefix is required these days */
-webkit-transform: translateZ(0);
transform: translateZ(0);
}
.caption::before {
content: ' ';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: transparent;
transition: background .35s ease-out;
}
.caption:hover::before {
background: rgba(0, 0, 0, .5);
}
.caption__media {
display: block;
min-width: 100%;
max-width: 100%;
height: auto;
}
.caption__overlay {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding: 10px;
color: white;
-webkit-transform: translateY(100%);
transform: translateY(100%);
transition: -webkit-transform .35s ease-out;
transition: transform .35s ease-out;
}
.caption:hover .caption__overlay {
-webkit-transform: translateY(0);
transform: translateY(0);
}
.caption__overlay__title {
-webkit-transform: translateY( -webkit-calc(-100% - 10px) );
transform: translateY( calc(-100% - 10px) );
transition: -webkit-transform .35s ease-out;
transition: transform .35s ease-out;
}
.caption:hover .caption__overlay__title {
-webkit-transform: translateY(0);
transform: translateY(0);
}
This is probably what you're looking for.
.hvrbox,
.hvrbox * {
box-sizing: border-box;
}
.hvrbox {
position: relative;
display: inline-block;
overflow: hidden;
max-width: 400px;
height: auto;
}
.hvrbox img {
max-width: 100%;
}
.hvrbox-text a {
text-decoration: none;
color: #ffffff;
font-weight: 700;
padding: 5px;
border: 2px solid #ffffff;
}
.hvrbox .hvrbox-layer_bottom {
display: block;
}
.hvrbox .hvrbox-layer_top {
opacity: 0;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.6);
color: #fff;
padding: 15px;
-moz-transition: all 0.4s ease-in-out 0s;
-webkit-transition: all 0.4s ease-in-out 0s;
-ms-transition: all 0.4s ease-in-out 0s;
transition: all 0.4s ease-in-out 0s;
}
.hvrbox:hover .hvrbox-layer_top,
.hvrbox.active .hvrbox-layer_top {
opacity: 1;
}
.hvrbox .hvrbox-text {
text-align: center;
font-size: 18px;
display: inline-block;
position: absolute;
top: 50%;
left: 50%;
-moz-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.hvrbox .hvrbox-text_mobile {
font-size: 15px;
border-top: 1px solid rgb(179, 179, 179);
/* for old browsers */
border-top: 1px solid rgba(179, 179, 179, 0.7);
margin-top: 5px;
padding-top: 2px;
display: none;
}
.hvrbox.active .hvrbox-text_mobile {
display: block;
}
.hvrbox .hvrbox-layer_slideup {
-moz-transform: translateY(100%);
-webkit-transform: translateY(100%);
-ms-transform: translateY(100%);
transform: translateY(100%);
}
.hvrbox:hover .hvrbox-layer_slideup,
.hvrbox.active .hvrbox-layer_slideup {
-moz-transform: translateY(0);
-webkit-transform: translateY(0);
-ms-transform: translateY(0);
transform: translateY(0);
}
<div class="hvrbox">
<img src="https://picsum.photos/5760/3840?image=1067" alt="Mountains" class="hvrbox-layer_bottom">
<div class="hvrbox-layer_top hvrbox-layer_slideup">
<div class="hvrbox-text">Take me to Goolge</div>
</div>
</div>

Internet Explorer 11 - Different behavior on measuring percent?

I have a tricky problem which I have been unable to solve.
$(".btn-nav").on("click tap", function() {
$(".nav-container")
.toggleClass("showNav hideNav")
.removeClass("hidden");
$(this).toggleClass("animated");
});
html {
margin: 0 auto;
height: 100% -ms-content-zooming: none;
-ms-touch-action: pan-x pan-y;
-webkit-content-zooming: none;
content-zooming: none;
}
body {
font-family: 'PT Sans', arial, serif;
margin: 0;
background-color: black;
}
button {
z-index: 1070;
background: none;
border: none;
}
button::-moz-focus-inner {
border: 0
}
:focus {
outline: none
}
::-moz-focus-inner {
border: 0
}
.btn-nav:hover {
cursor: pointer
}
.btn-nav:hover .bar {
background: #17BEBB
}
.bar {
display: block;
height: 50%;
width: 100%;
background: #fff;
margin: 22% auto;
}
.btn-nav {
z-index: 1070;
display: block;
padding: 0.8% 0;
width: 3%;
height: 4%;
position: fixed;
left: 2%;
margin: 0 auto;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-ms-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
.btn-nav:focus {
outline: none
}
.middle {
margin: 0 auto
}
.bar {
-webkit-transition: all .7s ease;
-moz-transition: all .7s ease;
-ms-transition: all .7s ease;
-o-transition: all .7s ease;
transition: all .7s ease;
}
.animated {
z-index: 1070;
}
.animated .arrow-top-r {
-webkit-transform: rotateZ(-45deg) translateY(180%);
-moz-transform: rotateZ(-45deg) translateY(180%);
-ms-transform: rotateZ(-45deg) translateY(180%);
-o-transform: rotateZ(-45deg) translateY(180%);
transform: rotateZ(-45deg) translateY(180%);
width: 55%;
}
.animated .arrow-middle-r {
-webkit-transform: translateX(50%);
-moz-transform: translateX(50%);
-ms-transform: translateX(50%);
-o-transform: translateX(50%);
transform: translateX(50%);
}
.animated .arrow-bottom-r {
-webkit-transform: rotateZ(45deg) translateY(-180%);
-moz-transform: rotateZ(45deg) translateY(-180%);
-ms-transform: rotateZ(45deg) translateY(-180%);
-o-transform: rotateZ(45deg) translateY(-180%);
transform: rotateZ(45deg) translateY(-180%);
width: 55%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<button class="btn-nav">
<div class="bar arrow-top-r"></div>
<div class="bar arrow-middle-r"></div>
<div class="bar arrow-bottom-r"></div>
</button>
</body>
https://jsfiddle.net/6t04y9wo/6/
As you can see, the top-left navigation button is shown differently between Chrome and IE.
I tried to get everything work in percent units to avoid incompatibility with 4k monitors (or very different resolutions) or zooming (which is really hard to avoid on a touchscreen-monitor+ windows).
As far as I can see, the height of the buttonelement is measured really differently, and so the inner heights will be. I've tried many different settings for that, but I can't get it work and look good for both Chrome and Internet Explorer.
It seems that the margin here:
.bar {
display: block;
height: 50%;
width: 100%;
background: #fff;
margin: 22% auto;
}
Is not correct, but I don't know how to fix it.
Maybe there is someone with some useful hints?
This would appear to be due to IE not calculating the height of the button correctly.
When using position: fixed; the position and dimensions of the element should be calculated in relation to the initial containing block:
Whereas the position and dimensions of an element with position:absolute are relative to its containing block, the position and dimensions of an element with position:fixed are always relative to the initial containing block. This is normally the viewport: the browser window or the paper’s page box.
Fixed positioning (https://www.w3.org/wiki/CSS_absolute_and_fixed_positioning)
It appears that IE is sizing the button in relation to the body. As you are using percentage height and no height has been specified on body this will result in the height for the button being set as auto. This can be overcome by adding height: 100%; to body so that the button's height can be calculated in relation to it.
The height of the bars in the button is set to 50% which with the padding will mean they exceed the height of the button. To overcome this you should set overflow: visible; on the button to allow them to be visible.
There is also a small typo that you will want to fix:
height: 100% -ms-content-zooming: none;
Should be:
height: 100%;
-ms-content-zooming: none;
You may also want to set a min-height and min-width to ensure the button shows when the viewport height is very small.
$(".btn-nav").on("click tap", function() {
$(".nav-container")
.toggleClass("showNav hideNav")
.removeClass("hidden");
$(this).toggleClass("animated");
});
html {
margin: 0 auto;
height: 100%;
-ms-content-zooming: none;
-ms-touch-action: pan-x pan-y;
-webkit-content-zooming: none;
content-zooming: none;
}
body {
height: 100%;
font-family: 'PT Sans', arial, serif;
margin: 0;
background-color: black;
}
button {
overflow: visible;
z-index: 1070;
background: none;
border: none;
}
button::-moz-focus-inner {
border: 0
}
:focus {
outline: none
}
::-moz-focus-inner {
border: 0
}
.btn-nav:hover {
cursor: pointer
}
.btn-nav:hover .bar {
background: #17BEBB
}
.bar {
display: block;
height: 50%;
width: 100%;
background: #fff;
margin: 22% auto;
}
.btn-nav {
z-index: 1070;
display: block;
padding: 0.8% 0;
width: 3%;
height: 4%;
position: fixed;
left: 2%;
margin: 0 auto;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-ms-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
min-height: 20px;
min-width: 50px;
}
.btn-nav:focus {
outline: none
}
.middle {
margin: 0 auto
}
.bar {
-webkit-transition: all .7s ease;
-moz-transition: all .7s ease;
-ms-transition: all .7s ease;
-o-transition: all .7s ease;
transition: all .7s ease;
}
.animated {
z-index: 1070;
}
.animated .arrow-top-r {
-webkit-transform: rotateZ(-45deg) translateY(180%);
-moz-transform: rotateZ(-45deg) translateY(180%);
-ms-transform: rotateZ(-45deg) translateY(180%);
-o-transform: rotateZ(-45deg) translateY(180%);
transform: rotateZ(-45deg) translateY(180%);
width: 55%;
}
.animated .arrow-middle-r {
-webkit-transform: translateX(50%);
-moz-transform: translateX(50%);
-ms-transform: translateX(50%);
-o-transform: translateX(50%);
transform: translateX(50%);
}
.animated .arrow-bottom-r {
-webkit-transform: rotateZ(45deg) translateY(-180%);
-moz-transform: rotateZ(45deg) translateY(-180%);
-ms-transform: rotateZ(45deg) translateY(-180%);
-o-transform: rotateZ(45deg) translateY(-180%);
transform: rotateZ(45deg) translateY(-180%);
width: 55%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<button class="btn-nav">
<div class="bar arrow-top-r"></div>
<div class="bar arrow-middle-r"></div>
<div class="bar arrow-bottom-r"></div>
</button>
</body>
Alternatively, you could use viewport units to specify the dimensions of the button.
$(".btn-nav").on("click tap", function() {
$(".nav-container")
.toggleClass("showNav hideNav")
.removeClass("hidden");
$(this).toggleClass("animated");
});
html {
margin: 0 auto;
height: 100%;
-ms-content-zooming: none;
-ms-touch-action: pan-x pan-y;
-webkit-content-zooming: none;
content-zooming: none;
}
body {
font-family: 'PT Sans', arial, serif;
margin: 0;
background-color: black;
}
button {
overflow: visible;
z-index: 1070;
background: none;
border: none;
}
button::-moz-focus-inner {
border: 0
}
:focus {
outline: none
}
::-moz-focus-inner {
border: 0
}
.btn-nav:hover {
cursor: pointer
}
.btn-nav:hover .bar {
background: #17BEBB
}
.bar {
display: block;
height: 50%;
width: 100%;
background: #fff;
margin: 22% auto;
}
.btn-nav {
z-index: 1070;
display: block;
padding: 0.8% 0;
width: 4vh;
height: 4vh;
position: fixed;
left: 2%;
margin: 0 auto;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-ms-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
min-height: 20px;
min-width: 50px;
}
.btn-nav:focus {
outline: none
}
.middle {
margin: 0 auto
}
.bar {
-webkit-transition: all .7s ease;
-moz-transition: all .7s ease;
-ms-transition: all .7s ease;
-o-transition: all .7s ease;
transition: all .7s ease;
}
.animated {
z-index: 1070;
}
.animated .arrow-top-r {
-webkit-transform: rotateZ(-45deg) translateY(180%);
-moz-transform: rotateZ(-45deg) translateY(180%);
-ms-transform: rotateZ(-45deg) translateY(180%);
-o-transform: rotateZ(-45deg) translateY(180%);
transform: rotateZ(-45deg) translateY(180%);
width: 55%;
}
.animated .arrow-middle-r {
-webkit-transform: translateX(50%);
-moz-transform: translateX(50%);
-ms-transform: translateX(50%);
-o-transform: translateX(50%);
transform: translateX(50%);
}
.animated .arrow-bottom-r {
-webkit-transform: rotateZ(45deg) translateY(-180%);
-moz-transform: rotateZ(45deg) translateY(-180%);
-ms-transform: rotateZ(45deg) translateY(-180%);
-o-transform: rotateZ(45deg) translateY(-180%);
transform: rotateZ(45deg) translateY(-180%);
width: 55%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<button class="btn-nav">
<div class="bar arrow-top-r"></div>
<div class="bar arrow-middle-r"></div>
<div class="bar arrow-bottom-r"></div>
</button>
</body>
Just use pixels, 4k displays are scaled, my uhd notebook shows exactly the same page when I'm looking at a page with a 1200px width body.

CSS transform effect works on all browsers except Safari

.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;
}

2nd image appears as mirror image in IE--- CSS image FLIP transform- How to fix?

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;
}