I have an image which on hover displays the title of a video. I want to be able to click after hovering and have my iframe show up. I have been able to simply put the vimeo player in to pop up, but whenever I want to put the iframe in, it doesn't work. I understand I can't wrap it inside the tag but I don't know another solution. Right now if you input the code, on hover the iframe appears. I want for it to not appear on hover, but appear when I click. Any help would be appreciated.
CODE:
<style>
.hoverfollow {
position: fixed;
}
.hvrbox,
.hvrbox * {
box-sizing: border-box;
}
.hvrbox {
position: relative;
display: inline-block;
overflow: hidden;
width: 30%;
height: auto;
}
.hvrbox img {
max-width: 100%;
}
.hvrbox_background {
width: 400px;
height: 250px;
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
}
.hvrbox .hvrbox-layer_bottom {
display: block;
}
.hvrbox .hvrbox-layer_top {
text-decoration: none;
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-family: "DIN";
font-size: 10px;
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%);
width: 100%;
height: auto;
}
.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_image {
padding: 0;
background: none;
}
.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);
}
.hvrbox .hvrbox-layer_slidedown {
-moz-transform: translateY(-100%);
-webkit-transform: translateY(-100%);
-ms-transform: translateY(-100%);
transform: translateY(-100%);
}
.hvrbox:hover .hvrbox-layer_slidedown,
.hvrbox.active .hvrbox-layer_slidedown {
-moz-transform: translateY(0);
-webkit-transform: translateY(0);
-ms-transform: translateY(0);
transform: translateY(0);
}
.hvrbox .hvrbox-layer_slideleft {
-moz-transform: translateX(100%);
-webkit-transform: translateX(100%);
-ms-transform: translateX(100%);
transform: translateX(100%);
}
.hvrbox:hover .hvrbox-layer_slideleft,
.hvrbox.active .hvrbox-layer_slideleft {
-moz-transform: translateX(0);
-webkit-transform: translateX(0);
-ms-transform: translateX(0);
transform: translateX(0);
}
.hvrbox .hvrbox-layer_slideright {
-moz-transform: translateX(-100%);
-webkit-transform: translateX(-100%);
-ms-transform: translateX(-100%);
transform: translateX(-100%);
}
.hvrbox:hover .hvrbox-layer_slideright,
.hvrbox.active .hvrbox-layer_slideright {
-moz-transform: translateX(0);
-webkit-transform: translateX(0);
-ms-transform: translateX(0);
transform: translateX(0);
}
.hvrbox .hvrbox-layer_scale {
border-radius: 50%;
-moz-transform: scale(0);
-webkit-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
}
.hvrbox:hover .hvrbox-layer_scale,
.hvrbox.active .hvrbox-layer_scale {
border-radius: 0%;
-moz-transform: scale(1);
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
.hvrbox .hvrbox-layer_rotate {
border-radius: 50%;
-moz-transform: rotateZ(0);
-webkit-transform: rotateZ(0);
-ms-transform: rotateZ(0);
transform: rotateZ(0);
}
.hvrbox:hover .hvrbox-layer_rotate,
.hvrbox.active .hvrbox-layer_rotate {
border-radius: 0%;
-moz-transform: rotateZ(360deg);
-webkit-transform: rotateZ(360deg);
-ms-transform: rotateZ(360deg);
transform: rotateZ(360deg);
}
.hvrbox .hvrbox-layer_scale-rotate {
border-radius: 50%;
-moz-transform: scale(0) rotateZ(0);
-webkit-transform: scale(0) rotateZ(0);
-ms-transform: scale(0) rotateZ(0);
transform: scale(0) rotateZ(0);
}
.hvrbox:hover .hvrbox-layer_scale-rotate,
.hvrbox.active .hvrbox-layer_scale-rotate {
border-radius: 0%;
-moz-transform: scale(1) rotateZ(360deg);
-webkit-transform: scale(1) rotateZ(360deg);
-ms-transform: scale(1) rotateZ(360deg);
transform: scale(1) rotateZ(360deg);
}
body,
p,
a,
h1,
h2,
h3,
h4,
h5,
h6,
div {
font-family: "DIN", sans-serif !important;
margin: 0;
text-decoration: none;
}
header {
background: #009FDA none repeat scroll 0% 0%;
box-shadow: 0px 0px 4px rgba(84, 84, 84, 0.5);
padding: 5px 15px;
color: #fff;
text-align: center;
overflow: hidden;
}
header img {
height: 50px;
float: left;
}
header h1 {
text-transform: uppercase;
font-weight: 400;
font-size: 26px;
line-height: 48px;
}
.content h1,
.content h2,
.content h3 {
margin: 15px 0 0px 0;
}
.content {
max-width: 1200px;
margin: 50px auto 0 auto;
width: 100%;
}
pre {
background: #F2F2F2 none repeat scroll 0% 0%;
font-size: 15px;
padding: 10px;
border-radius: 3px;
margin: 10px 0;
white-space: pre-wrap;
-ms-tab-size: 4;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
}
footer {
background: #000;
color: #fff;
padding: 10px;
font-size: 13px;
}
footer a {
color: inherit;
text-decoration: none;
}
footer a:hover,
footer a:focus {
text-decoration: underline;
}
.align {
top: 5%;
left: 5%;
}
iframe {
width: 700px;
/* adjust to your needs */
max-width: 100%;
/* to make it responsive */
animation-name: fadeIn;
animation-duration: 4s;
}
#amaka {
width: 100%;
height: auto;
margin-top: 5%;
animation-name: fadeIn;
animation-duration: 4s;
}
</style>
<main>
<a class="align" href="test">
<div class="hvrbox align">
<img id="amaka" src="http://www.noscht.com/wp-content/uploads/2020/07/amaka.png" alt="AMAKA" class="hvrbox-layer_bottom">
<div class="hvrbox-layer_top">
<div class="hvrbox-text">
AMAKA QUEENETTE - "SUFFOCATE"</div>
Remove the source attribute of your IFrame and only set it onClick
Give your IFrame a unique identifier so you can find it with document.getElementById().
<iframe id='myIframe' frameborder="0" scrolling="no" width="550" height="400">
The IFrame should then have a source. You can set the source for example like this:
document.getElementById("myIframe").src = "https://yoursource.com"
Now add this code inside the onClick attribute to your element you want the user to click on.
onClick='document.getElementById("myIframe").src="https://yoursource.com"
So your full HTML could look like this:
<iframe id='myIframe' frameborder="0" scrolling="no" width="550" height="400">
<p onClick="document.getElementById("myIframe").src="https://yoursource.com"">Click here</p>
.hoverfollow {
position: fixed;
}
.hvrbox,
.hvrbox * {
box-sizing: border-box;
}
.hvrbox {
position: relative;
display: inline-block;
overflow: hidden;
width: 30%;
height: auto;
}
.hvrbox img {
max-width: 100%;
}
.hvrbox_background {
width: 400px;
height: 250px;
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
}
.hvrbox .hvrbox-layer_bottom {
display: block;
}
.hvrbox .hvrbox-layer_top {
text-decoration: none;
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-family: "DIN";
font-size: 10px;
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%);
width: 100%;
height: auto;
}
.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_image {
padding: 0;
background: none;
}
.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);
}
.hvrbox .hvrbox-layer_slidedown {
-moz-transform: translateY(-100%);
-webkit-transform: translateY(-100%);
-ms-transform: translateY(-100%);
transform: translateY(-100%);
}
.hvrbox:hover .hvrbox-layer_slidedown,
.hvrbox.active .hvrbox-layer_slidedown {
-moz-transform: translateY(0);
-webkit-transform: translateY(0);
-ms-transform: translateY(0);
transform: translateY(0);
}
.hvrbox .hvrbox-layer_slideleft {
-moz-transform: translateX(100%);
-webkit-transform: translateX(100%);
-ms-transform: translateX(100%);
transform: translateX(100%);
}
.hvrbox:hover .hvrbox-layer_slideleft,
.hvrbox.active .hvrbox-layer_slideleft {
-moz-transform: translateX(0);
-webkit-transform: translateX(0);
-ms-transform: translateX(0);
transform: translateX(0);
}
.hvrbox .hvrbox-layer_slideright {
-moz-transform: translateX(-100%);
-webkit-transform: translateX(-100%);
-ms-transform: translateX(-100%);
transform: translateX(-100%);
}
.hvrbox:hover .hvrbox-layer_slideright,
.hvrbox.active .hvrbox-layer_slideright {
-moz-transform: translateX(0);
-webkit-transform: translateX(0);
-ms-transform: translateX(0);
transform: translateX(0);
}
.hvrbox .hvrbox-layer_scale {
border-radius: 50%;
-moz-transform: scale(0);
-webkit-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
}
.hvrbox:hover .hvrbox-layer_scale,
.hvrbox.active .hvrbox-layer_scale {
border-radius: 0%;
-moz-transform: scale(1);
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
.hvrbox .hvrbox-layer_rotate {
border-radius: 50%;
-moz-transform: rotateZ(0);
-webkit-transform: rotateZ(0);
-ms-transform: rotateZ(0);
transform: rotateZ(0);
}
.hvrbox:hover .hvrbox-layer_rotate,
.hvrbox.active .hvrbox-layer_rotate {
border-radius: 0%;
-moz-transform: rotateZ(360deg);
-webkit-transform: rotateZ(360deg);
-ms-transform: rotateZ(360deg);
transform: rotateZ(360deg);
}
.hvrbox .hvrbox-layer_scale-rotate {
border-radius: 50%;
-moz-transform: scale(0) rotateZ(0);
-webkit-transform: scale(0) rotateZ(0);
-ms-transform: scale(0) rotateZ(0);
transform: scale(0) rotateZ(0);
}
.hvrbox:hover .hvrbox-layer_scale-rotate,
.hvrbox.active .hvrbox-layer_scale-rotate {
border-radius: 0%;
-moz-transform: scale(1) rotateZ(360deg);
-webkit-transform: scale(1) rotateZ(360deg);
-ms-transform: scale(1) rotateZ(360deg);
transform: scale(1) rotateZ(360deg);
}
body,
p,
a,
h1,
h2,
h3,
h4,
h5,
h6,
div {
font-family: "DIN", sans-serif !important;
margin: 0;
text-decoration: none;
}
header {
background: #009FDA none repeat scroll 0% 0%;
box-shadow: 0px 0px 4px rgba(84, 84, 84, 0.5);
padding: 5px 15px;
color: #fff;
text-align: center;
overflow: hidden;
}
header img {
height: 50px;
float: left;
}
header h1 {
text-transform: uppercase;
font-weight: 400;
font-size: 26px;
line-height: 48px;
}
.content h1,
.content h2,
.content h3 {
margin: 15px 0 0px 0;
}
.content {
max-width: 1200px;
margin: 50px auto 0 auto;
width: 100%;
}
pre {
background: #F2F2F2 none repeat scroll 0% 0%;
font-size: 15px;
padding: 10px;
border-radius: 3px;
margin: 10px 0;
white-space: pre-wrap;
-ms-tab-size: 4;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
}
footer {
background: #000;
color: #fff;
padding: 10px;
font-size: 13px;
}
footer a {
color: inherit;
text-decoration: none;
}
footer a:hover,
footer a:focus {
text-decoration: underline;
}
.align {
top: 5%;
left: 5%;
}
iframe {
width: 700px;
/* adjust to your needs */
max-width: 100%;
/* to make it responsive */
animation-name: fadeIn;
animation-duration: 4s;
}
#amaka {
width: 100%;
height: auto;
margin-top: 5%;
animation-name: fadeIn;
animation-duration: 4s;
}
#myIframe {}
<main>
<div class="hvrbox align">
<img id="amaka" src="http://www.noscht.com/wp-content/uploads/2020/07/amaka.png" alt="AMAKA" class="hvrbox-layer_bottom">
<a href="#">
<div onClick='document.getElementById("myIframe").src="https://player.vimeo.com/video/389137312"' class="hvrbox-layer_top"></div>
</a>
<div class="hvrbox-text">
AMAKA QUEENETTE - "SUFFOCATE"</div>
<iframe id="myIframe" onClick="https://player.vimeo.com/video/389137312" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>
</div>
</main>
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background: #eaeaea;
}
.stage {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
perspective: 1800px;
transform-style: preserve-3d;
}
.box {
position: absolute;
top: 50%;
left: 50%;
width: 3.75rem;
height: 3.75rem;
transform-style: preserve-3d;
transform: rotateX(-35deg) rotateY(45deg);
}
.box:nth-child(1) {
animation: box 4s linear;
}
.box:nth-child(1) .left {
animation: left-side 4s linear;
}
.box:nth-child(1) .right {
animation: right-side 4s linear;
}
.box .front,
.box .back,
.box .top,
.box .bottom,
.box .left,
.box .right {
position: absolute;
top: 0;
left: 0;
width: 3.75rem;
height: 3.75rem;
transform-origin: center center;
}
.box .front {
background: #665867;
transform: translateZ(1.875rem);
}
.box .back {
background: #665867;
transform: translateZ(-1.875rem);
}
.box .top {
background: #706171;
transform: translateY(-50%) rotateX(90deg);
}
.box .bottom {
background: #423943;
transform: translateY(50%) rotateX(90deg);
}
.box .left {
background: #776778;
transform: translateX(-50%) rotateY(90deg);
}
.box .right {
background: #524652;
transform: translateX(50%) rotateY(90deg);
}
#keyframes box {
0% {
transform: rotateX(-35deg) rotateY(45deg) translateX(-100px);
}
20% {
transform: rotateX(-35deg) rotateY(45deg) translateX(100px);
}
25% {
transform: rotateX(-35deg) rotateY(45deg) translateX(100px) rotateY(90deg);
}
45% {
transform: translateX(100px) rotateX(-35deg) rotateY(135deg) translateX(200px);
}
50% {
transform: translateX(100px) rotateX(-35deg) rotateY(135deg) translateX(200px) rotateY(90deg);
}
70% {
transform: translateX(-100px) rotateX(-35deg) rotateY(225deg) translateX(100px);
}
75% {
transform: translateX(-100px) rotateX(-35deg) rotateY(225deg) translateX(100px) rotateY(90deg);
}
95% {
transform: translateX(0px) rotateX(-35deg) rotateY(315deg) translateX(100px);
}
100% {
transform: translateX(0px) rotateX(-35deg) rotateY(315deg) translateX(-100px) rotateY(90deg);
}
}
<div class="stage">
<div class="box">
<div class="front"></div>
<div class="back"></div>
<div class="top"></div>
<div class="bottom"></div>
<div class="left"></div>
<div class="right"></div>
</div>
</div>
I'm trying to make a 3D cube move along the path of a rhombus. In each corner of the rhombus (there are 4 of them), it should rotate 90 degrees and continue to move. I managed to do half of the animation path correctly, but in the rest of the animation (after 50%) some kind of nonsense occurs. What am I doing wrong?
You need to keep adding a new transformation to all the previous one without changing them to have a continuous animation. Each step you either translate or rotate until you finish all the path and you get back to the initial one.
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background: #eaeaea;
}
.stage {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
perspective: 1800px;
transform-style: preserve-3d;
}
.box {
position: absolute;
top: 50%;
left: 50%;
width: 3.75rem;
height: 3.75rem;
transform-style: preserve-3d;
transform: rotateX(-35deg) rotateY(45deg);
}
.box:nth-child(1) {
animation: box 4s linear infinite;
}
.box:nth-child(1) .left {
animation: left-side 4s linear;
}
.box:nth-child(1) .right {
animation: right-side 4s linear;
}
.box .front,
.box .back,
.box .top,
.box .bottom,
.box .left,
.box .right {
position: absolute;
top: 0;
left: 0;
width: 3.75rem;
height: 3.75rem;
transform-origin: center center;
}
.box .front {
background: #665867;
transform: translateZ(1.875rem);
}
.box .back {
background: #665867;
transform: translateZ(-1.875rem);
}
.box .top {
background: #706171;
transform: translateY(-50%) rotateX(90deg);
}
.box .bottom {
background: #423943;
transform: translateY(50%) rotateX(90deg);
}
.box .left {
background: #776778;
transform: translateX(-50%) rotateY(90deg);
}
.box .right {
background: #524652;
transform: translateX(50%) rotateY(90deg);
}
#keyframes box {
0% {
transform: rotateX(-35deg) rotateY(45deg);
}
20% {
transform: rotateX(-35deg) rotateY(45deg) translateX(100px);
}
25% {
transform: rotateX(-35deg) rotateY(45deg) translateX(100px) rotateY(90deg);
}
45% {
transform: rotateX(-35deg) rotateY(45deg) translateX(100px) rotateY(90deg) translateX(100px);
}
50% {
transform: rotateX(-35deg) rotateY(45deg) translateX(100px) rotateY(90deg) translateX(100px) rotateY(90deg);
}
70% {
transform: rotateX(-35deg) rotateY(45deg) translateX(100px) rotateY(90deg) translateX(100px) rotateY(90deg) translateX(100px);
}
75% {
transform: rotateX(-35deg) rotateY(45deg) translateX(100px) rotateY(90deg) translateX(100px) rotateY(90deg) translateX(100px) rotateY(90deg);
}
95% {
transform: rotateX(-35deg) rotateY(45deg) translateX(100px) rotateY(90deg) translateX(100px) rotateY(90deg) translateX(100px) rotateY(90deg) translateX(100px);
}
100% {
transform: rotateX(-35deg) rotateY(45deg) translateX(100px) rotateY(90deg) translateX(100px) rotateY(90deg) translateX(100px) rotateY(90deg) translateX(100px) rotateY(90deg);
}
}
<div class="stage">
<div class="box">
<div class="front"></div>
<div class="back"></div>
<div class="top"></div>
<div class="bottom"></div>
<div class="left"></div>
<div class="right"></div>
</div>
</div>
I successfully created a cube in a cube, a Tesseract. But for some reason I really can't explain, the cube is moving downwards while the Animation is going on.
If you watch the scrolling bar of your browser, the entire cube is moving downwards.
And yes, of course you can "ignore" this problem by changing the margin of the parent-div-element but that doesn't solve it.
#-webkit-keyframes cube-spin {
from {
-webkit-transform: rotateY(0deg);
transform: rotateY(0deg);
}
to {
-webkit-transform: rotateY(360deg);
transform: rotateY(360deg);
}
}
#keyframes cube-spin {
from {
-webkit-transform: rotateY(0deg);
transform: rotateY(0deg);
}
to {
-webkit-transform: rotateY(360deg);
transform: rotateY(360deg);
}
}
#-webkit-keyframes counter-rot {
from {
-webkit-transform: rotateY(0deg);
transform: rotateY(0deg);
}
to {
-webkit-transform: rotateY(-360deg);
transform: rotateY(-360deg);
}
}
#keyframes counter-rot {
from {
-webkit-transform: rotateY(0deg);
transform: rotateY(0deg);
}
to {
-webkit-transform: rotateY(-360deg);
transform: rotateY(-360deg);
}
}
.cube-wrap {
-webkit-perspective: 800px;
perspective: 800px;
-webkit-perspective-origin: 50% 0%;
perspective-origin: 50% 0%;
}
.outer {
width: 300px !important;
}
.cube {
position: relative;
width: 200px;
margin: 0 auto;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-animation: cube-spin 8s infinite linear;
animation: cube-spin 8s infinite linear;
}
.backendtext {
position: absolute;
width: 200px;
font-size: 35px;
text-align: center;
font-family: sans-serif;
text-transform: uppercase;
-webkit-animation: counter-rot 8s infinite linear;
animation: counter-rot 8s infinite linear;
}
.outer div {
width: 300px;
height: 300px;
background: rgba(255, 116, 0, 0.1);
line-height: 530px;
}
.inner div {
width: 200px;
height: 200px;
background: rgba(153, 69, 0, 0.7);
}
.cube div {
position: absolute;
box-shadow: inset 0 0 30px rgba(125,125,125,0.8);
font-size: 35px;
text-align: center;
font-family: sans-serif;
text-transform: uppercase;
}
.depth div.front-pane {
-webkit-transform: translateY(-100px) translateZ(100px);
transform: translateY(-100px) translateZ(100px);
}
.outer.depth div.front-pane {
-webkit-transform: translateY(-150px) translateZ(150px);
transform: translateY(-150px) translateZ(150px);
}
.depth div.back-pane {
-webkit-transform: translateY(-100px) translateZ(-100px) rotateY(180deg);
transform: translateY(-100px) translateZ(-100px) rotateY(180deg);
}
.outer.depth div.back-pane {
-webkit-transform: translateY(-150px) translateZ(-150px) rotateY(180deg);
transform: translateY(-150px) translateZ(-150px) rotateY(180deg);
}
.depth div.left-pane {
-webkit-transform: translateY(-100px) translateX(100px) rotateY(-270deg);
transform: translateY(-100px) translateX(100px) rotateY(-270deg);
}
.outer.depth div.left-pane {
-webkit-transform: translateY(-150px) translateX(150px) rotateY(-270deg);
transform: translateY(-150px) translateX(150px) rotateY(-270deg);
}
.depth div.right-pane {
-webkit-transform: translateY(-100px) translateX(-100px) rotateY(270deg);
transform: translateY(-100px) translateX(-100px) rotateY(270deg);
}
.outer.depth div.right-pane {
-webkit-transform: translateY(-150px) translateX(-150px) rotateY(270deg);
transform: translateY(-150px) translateX(-150px) rotateY(270deg);
}
.depth div.top-pane {
-webkit-transform: translateY(-200px) rotateX(-90deg);
transform: translateY(-200px) rotateX(-90deg);
}
.outer.depth div.top-pane {
-webkit-transform: translateY(-300px) rotateX(-90deg);
transform: translateY(-300px) rotateX(-90deg);
}
.depth div.bottom-pane {
-webkit-transform: rotateX(90deg);
transform: rotateX(90deg);
}
<div style="height: 300px; margin-top: 400px;">
<div class="cube-wrap">
<div class="cube depth inner">
<a class="backendtext">Backend</a>
<div class="front-pane"></div>
<div class="back-pane"></div>
<div class="top-pane"></div>
<div class="bottom-pane"></div>
<div class="left-pane"></div>
<div class="right-pane"></div>
</div>
<div class="cube depth outer">
<div class="front-pane">Frontend</div>
<div class="back-pane">Frontend</div>
<div class="top-pane"></div>
<div class="bottom-pane"></div>
<div class="left-pane">Frontend</div>
<div class="right-pane">Frontend</div>
</div>
</div>
//EDIT: Works fine on Chrome and Edge. Will try to add prefixes to everything and see if it solves the problem.
//EDIT2: Added Prefixes, still doesn't work on Firefox but does properly on Chrome, Edge etc.
//EDIT3: Set Overflow of the cube-wrapper to hidden but I would still love to know the reason.
So what i want is: when cursor goes over the image (diamond), no to activate the hover of the octagon.
Here is the example:
http://codepen.io/Chrez/pen/yYajGo
<li>
<a href="#">
<div class="octagonFirst">
<div class="octagonIn1">
<div class="octagonIn2">
<div class="octagonIn3"></div>
</div>
</div>
<span class="text First">Startseite</span>
<div class="diamond"></div>
</div>
</a>
</li>
CCS:
body {
background-color: #ba2020;
}
.octagonFirst {
width: 164px;
height: 68px;
position: absolute;
background: black;
top: 200px;
left: 1000px;
color: white;
font-size: 30px;
-webkit-transform: rotate(-16deg);
-moz-transform: rotate(-16deg);
-ms-transform: rotate(-16deg);
-o-transform: rotate(-16deg);
transform: rotate(-16deg);
}
.octagonIn1 {
width: 100%;
height: 100%;
background: inherit;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
.octagonIn2 {
width: 100%;
height: 100%;
display: inherit;
background: inherit;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-ms-transform: rotate(90deg);
-o-transform: rotate(90deg);
transform: rotate(90deg);
}
.octagonIn3 {
width: 100%;
height: 100%;
display: inherit;
background: inherit;
-webkit-transform: rotate(135deg);
-moz-transform: rotate(135deg);
-ms-transform: rotate(135deg);
-o-transform: rotate(135deg);
transform: rotate(135deg);
}
.text {
display: block;
position: absolute;
z-index: 1000;
-webkit-transform: rotate(16deg);
-moz-transform: rotate(16deg);
-ms-transform: rotate(16deg);
-o-transform: rotate(16deg);
transform: rotate(16deg);
}
.First {
left: 35px;
top: 10px;
}
.octagonFirst:hover {
background: white;
color: black;
}
.diamond {
width: 206px;
height: 202px;
position: absolute;
background-image: url('http://i.imgur.com/Yyv3dht.png');
top: 0;
}
Add pointer-events: none; to .diamond
codepen
body {
background-color: #ba2020;
}
.octagonFirst {
width: 164px;
height: 68px;
position: absolute;
background: black;
top: 200px;
left: 1000px;
color: white;
font-size: 30px;
-webkit-transform: rotate(-16deg);
-moz-transform: rotate(-16deg);
-ms-transform: rotate(-16deg);
-o-transform: rotate(-16deg);
transform: rotate(-16deg);
}
.octagonIn1 {
width: 100%;
height: 100%;
background: inherit;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
.octagonIn2 {
width: 100%;
height: 100%;
display: inherit;
background: inherit;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-ms-transform: rotate(90deg);
-o-transform: rotate(90deg);
transform: rotate(90deg);
}
.octagonIn3 {
width: 100%;
height: 100%;
display: inherit;
background: inherit;
-webkit-transform: rotate(135deg);
-moz-transform: rotate(135deg);
-ms-transform: rotate(135deg);
-o-transform: rotate(135deg);
transform: rotate(135deg);
}
.text {
display: block;
position: absolute;
z-index: 1000;
-webkit-transform: rotate(16deg);
-moz-transform: rotate(16deg);
-ms-transform: rotate(16deg);
-o-transform: rotate(16deg);
transform: rotate(16deg);
}
.First {
left: 35px;
top: 10px;
}
.octagonFirst:hover {
background: white;
color: black;
}
.diamond {
width: 206px;
height: 202px;
position: absolute;
background-image: url('http://i.imgur.com/Yyv3dht.png');
top: 0;
pointer-events: none;
}
<li>
<a href="#">
<div class="octagonFirst">
<div class="octagonIn1">
<div class="octagonIn2">
<div class="octagonIn3"></div>
</div>
</div>
<span class="text First">Startseite</span>
<div class="diamond"></div>
</div>
</a>
</li>
I have problem to running My CSS3 3D flip Animation in IE Browser. The problem is backface-visibility CSS3 is not work. So if box was flipped, the back box is not showing.
Below is my code
CSS
.flip-container {
-ms-perspective: 1000px;
-webkit-perspective: 1000px;
perspective: 1000px;
position: absolute;
top: 50%;
left: 50%;
margin: -75px 0 0 -75px;
}
.click {
cursor: pointer;
}
.flip-container, .front, .back, .behind {
width: 150px;
height: 150px;
background-color: #d5d5d5;
}
/* flip parent stylesheet */
.flipper-up,
.flipper-right,
.flipper-bottom,
.flipper-left,
.behind {
position: absolute;
top:0;
left: 0;
right:0;
bottom:0;
-ms-transition: 0.8s;
-webkit-transition: 0.8s;
transition: 0.8s;
-ms-transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
}
/* hide back of pane during swap */
.flipper-up .front, .flipper-up .back,
.flipper-right .front, .flipper-right .back,
.flipper-bottom .front, .flipper-bottom .back,
.flipper-left .front, .flipper-left .back {
color: #fff;
font-size: 32px;
text-align: center;
line-height: 150px;
-ms-backface-visibility: hidden;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom:0;
}
.behind {
z-index: 0;
background-color: purple;
text-align: center;
line-height: 150px;
cursor: pointer;
}
.click {
cursor: pointer;
}
/* Flip to up */
.flipper-up {
z-index: 5;
-ms-transform-origin: top left;
-webkit-transform-origin: top left;
transform-origin: top left;
}
.flipper-up > .front {
/* for firefox 31 */
background-color: red;
-ms-transform: rotateX(0deg);
-webkit-transform: rotateX(0deg);
transform: rotateX(0deg);
}
/* back, initially hidden pane */
.flipper-up > .back {
background-color: red;
-ms-transform: rotateX(180deg);
-webkit-transform: rotateX(180deg);
transform: rotateX(180deg);
}
.flip.flipper-up {
-ms-transform: rotateX(180deg);
-webkit-transform: rotateX(180deg);
transform: rotateX(180deg);
}
/* Flip to right */
.flipper-right {
z-index: 3;
-ms-transform-origin: top right;
-webkit-transform-origin: top right;
transform-origin: top right;
}
.flipper-right > .front {
/* for firefox 31 */
background-color: blue;
-ms-transform: rotateX(0deg);
-webkit-transform: rotateX(0deg);
transform: rotateX(0deg);
}
/* back, initially hidden pane */
.flipper-right > .back {
background-color: blue;
-ms-transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.flip.flipper-right {
-ms-transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
}
/* Flip to bottom */
.flipper-bottom {
z-index: 1;
-ms-transform-origin: bottom left;
-webkit-transform-origin: bottom left;
transform-origin: bottom left;
}
.flipper-bottom > .front {
/* for firefox 31 */
background-color: green;
-ms-transform: rotateX(0deg);
-webkit-transform: rotateX(0deg);
transform: rotateX(0deg);
}
/* back, initially hidden pane */
.flipper-bottom > .back {
background-color: green;
-ms-transform: rotateX(180deg);
-webkit-transform: rotateX(180deg);
transform: rotateX(180deg);
}
.flip.flipper-bottom {
-ms-transform: rotateX(-180deg);
-webkit-transform: rotateX(-180deg);
transform: rotateX(-180deg);
}
/* Flip to left */
.flipper-left {
z-index: 4;
-ms-transform-origin: top left;
-webkit-transform-origin: top left;
transform-origin: top left;
}
.flipper-left > .front {
/* for firefox 31 */
background-color: black;
-ms-transform: rotateX(0deg);
-webkit-transform: rotateX(0deg);
transform: rotateX(0deg);
}
/* back, initially hidden pane */
.flipper-left > .back {
background-color: black;
-ms-transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.flip.flipper-left {
-ms-transform: rotateY(-180deg);
-webkit-transform: rotateY(-180deg);
transform: rotateY(-180deg);
}
.flip {
cursor: default !important;
z-index: 10;
}
HTML
<div class="flip-container">
<div class="click flipper-up">
<div class="front">
1
</div>
<div class="back">
2
</div>
</div>
<div class="click flipper-left">
<div class="front">
3
</div>
<div class="back">
4
</div>
</div>
<div class="click flipper-right">
<div class="front">
5
</div>
<div class="back">
6
</div>
</div>
<div class="click flipper-bottom">
<div class="front">
7
</div>
<div class="back">
8
</div>
</div>
<div class="behind" title="Click here to close the box!">
click to close
</div>
</div>
jQuery
$(document).ready(function() {
$('.click').click(function(){
$(this).addClass('flip');
});
$('.behind').click(function() {
setTimeout(function(){
//wait for card1 flip to finish and then flip 2
$(".flipper-bottom").removeClass('flip');
}, 300);
setTimeout(function(){
//wait for card1 flip to finish and then flip 2
$(".flipper-right").removeClass('flip');
}, 600);
setTimeout(function(){
//wait for card1 flip to finish and then flip 2
$(".flipper-left").removeClass('flip');
}, 900);
setTimeout(function(){
//wait for card1 flip to finish and then flip 2
$(".flipper-up").removeClass('flip');
}, 1200);
});
});
http://jsfiddle.net/dhanangpratama/jxz08xva/