I recently came across this pen on codepen https://codepen.io/joshnh/pen/paxbE
I have been playing around with this animation but am unable to get it working on any other browser other than chrome. I have tried all prefixes with transform and transitions. when I remove the perspective(500) property the animation works in firefox but not with the desired results. From what I've read it is something to do with the way chrome applies the perspective property to child elements differently than other browsers. Is there any work around to getting this type of animation working across all browsers?
This is what I have changed the css to in order to get it working in other browsers but nothing seems to help.
html {
height: 100%;
}
body {
position: absolute;
width: 100%;
height: 100%;
-moz-animation: myfade 5s;
-webkit-animation: myfade 5s;
animation: myfade 5s;
background: url("../img/screenbackground.jpg");
}
button {
position: absolute;
top: 0.6%;
margin-left: 2%;;
border: none;
background: #3a7999;
color: #f2f2f2;
padding: 10px;
font-size: 14px;
border-radius: 5px;
opacity: 0;
box-sizing: border-box;
-webkit-transition: all 500ms ease;
-moz-transition: all 500ms ease;
transition: all 500ms ease;
}
button:hover {
background: #000000;
color: #3a7999;
box-shadow: inset 0 0 0 3px #3a7999;
}
.imageWrapper {
background-color:transparent;
font-family: sans-serif;
font-size: 100%;
line-height: 20%;
margin: 0 auto;
padding: 1em;
width: 80%;
height: 60%;
margin-top: 3%;
}
figure {
float: left;
height: 12em;
margin: 3em;
margin-top: 1em;
margin-bottom: 0.5em;
width: 24em;
-webkit-transform: perspective(500);
-webkit-transform-style: preserve-3d;
-webkit-transition: .5s;
-moz-transform: perspective(500);
-moz-transform-style: preserve-3d;
-moz-transition: .5s;
transform: perspective(500);
transform-style: preserve-3d;
transition: .5s;
border-radius: 5px;
-webkit-animation: myflip;
-moz-animation: myflip;
-ms-animation: myflip;
animation: myflip 5s;
}
figure:hover {
-webkit-transform: perspective(500) rotateX(90deg) translateY(-48px)
translateZ(60px);
-moz-transform: perspective(500) rotateX(90deg) translateY(-48px)
translateZ(60px);
-ms-transform: perspective(500) rotateX(90deg) translateY(-48px)
translateZ(60px);
transform: perspective(500) rotateX(90deg) translateY(-48px)
translateZ(60px);
}
img {
background-color: #222;
box-shadow: 0 40px 30px -20px hsla(0,0%,0%,.25);
display: block;
height: 100%;
-webkit-transition: .5s;
-moz-transition: .5s;
transition: .5s;
}
figure:hover img {
box-shadow: none;
}
figcaption {
background-color: #222;
color: #fff;
padding: 1.5em;
-webkit-transform: rotateX(-90deg);
-webkit-transform-origin: 100% 0;
-webkit-transition: .5s;
-moz-transform: rotateX(-90deg);
-moz-transform-origin: 100% 0;
-moz-transition: .5s;
transform: rotateX(-90deg);
transform-origin: 100% 0;
transition: .5s;
}
figure:hover figcaption {
box-shadow: 0 20px 15px -10px hsla(0,0%,0%,.25);
}
h3 {
font-weight: bold;
}
#-webkit-keyframes myflip {
0% {
-webkit-transform: perspective(500) rotateX(90deg) translateZ(60px);
-moz-transform: perspective(500) rotateX(90deg) translateZ(60px);
-ms-transform: perspective(500) rotateX(90deg) translateZ(60px);
transform: perspective(500) rotateX(90deg) translateZ(60px);
}
50% {
-webkit-transform: perspective(500) rotateX(90deg) translateZ(60px);
-moz-transform: perspective(500) rotateX(90deg) translateZ(60px);
-ms-transform: perspective(500) rotateX(90deg) translateZ(60px);
transform: perspective(500) rotateX(90deg) translateZ(60px);
}
80% {
-webkit-transform: perspective(500) rotateX(90deg)
translateZ(60px);
-moz-transform: perspective(500) rotateX(90deg) translateZ(60px);
-ms-transform: perspective(500) rotateX(90deg) translateZ(60px);
transform: perspective(500) rotateX(90deg) translateZ(60px);
}
100% {
}
}
#-moz-keyframes myflip {
0% {
-webkit-transform: perspective(500) rotateX(90deg) translateZ(60px);
-moz-transform: perspective(500) rotateX(90deg) translateZ(60px);
-ms-transform: perspective(500) rotateX(90deg) translateZ(60px);
transform: perspective(500) rotateX(90deg) translateZ(60px);
}
50% {
-webkit-transform: perspective(500) rotateX(90deg) translateZ(60px);
-moz-transform: perspective(500) rotateX(90deg) translateZ(60px);
-ms-transform: perspective(500) rotateX(90deg) translateZ(60px);
transform: perspective(500) rotateX(90deg) translateZ(60px);
}
80% {
-webkit-transform: perspective(500) rotateX(90deg)
translateZ(60px);
-moz-transform: perspective(500) rotateX(90deg) translateZ(60px);
-ms-transform: perspective(500) rotateX(90deg) translateZ(60px);
transform: perspective(500) rotateX(90deg) translateZ(60px);
}
100% {
}
}
#keyframes myflip {
0% {
-webkit-transform: perspective(500) rotateX(90deg) translateZ(60px);
-moz-transform: perspective(500) rotateX(90deg) translateZ(60px);
-ms-transform: perspective(500) rotateX(90deg) translateZ(60px);
transform: perspective(500) rotateX(90deg) translateZ(60px);
}
50% {
-webkit-transform: perspective(500) rotateX(90deg) translateZ(60px);
-moz-transform: perspective(500) rotateX(90deg) translateZ(60px);
-ms-transform: perspective(500) rotateX(90deg) translateZ(60px);
transform: perspective(500) rotateX(90deg) translateZ(60px);
}
80% {
-webkit-transform: perspective(500) rotateX(90deg)
translateZ(60px);
-moz-transform: perspective(500) rotateX(90deg) translateZ(60px);
-ms-transform: perspective(500) rotateX(90deg) translateZ(60px);
transform: perspective(500) rotateX(90deg) translateZ(60px);
}
100% {
}
}
#-ms-keyframes myflip {
0% {
-webkit-transform: perspective(500) rotateX(90deg) translateZ(60px);
-moz-transform: perspective(500) rotateX(90deg) translateZ(60px);
-ms-transform: perspective(500) rotateX(90deg) translateZ(60px);
transform: perspective(500) rotateX(90deg) translateZ(60px);
}
50% {
-webkit-transform: perspective(500) rotateX(90deg) translateZ(60px);
-moz-transform: perspective(500) rotateX(90deg) translateZ(60px);
-ms-transform: perspective(500) rotateX(90deg) translateZ(60px);
transform: perspective(500) rotateX(90deg) translateZ(60px);
}
80% {
-webkit-transform: perspective(500) rotateX(90deg)
translateZ(60px);
-moz-transform: perspective(500) rotateX(90deg) translateZ(60px);
-ms-transform: perspective(500) rotateX(90deg) translateZ(60px);
transform: perspective(500) rotateX(90deg) translateZ(60px);
}
100% {
}
}
#-webkit-keyframes myfade {
0% {
opacity: 0;
}
100% {
opacity 1;
}
}
#-moz-keyframes myfade {
0% {
opacity: 0;
}
100% {
opacity 1;
}
}
#keyframes myfade {
0% {
opacity: 0;
}
100% {
opacity 1;
}
}
The CSS perspective property accepts length as parameter, which means you should use a unit like px.
Also, in order to see your pen working in Firefox, you should add the vendor-prefix-free version of the -webkit properties you're using and add a unit to the perspective property, like in perspective(500px). See modified pen.
I'm here again with another webkit css3 animation problem. I've tried absolutely everything, even over-defining CSS properties.
The problem I'm having is the hover animations are cutting to the end when hovering in and out on webkit. It also has some strangeness when activating and deactivating where it seems to remember old values and try to animate to them.
I'm wondering whether I'm just missing something here, or Chrome is just incredibly buggy recently. Here is an example:
$(".offcanvas").click(function() {
$('body').toggleClass('uk-offcanvas-page');
});
html,
body {
padding: 0;
margin: 0;
background: #de1b4a;
}
.center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
/* Bar */
header .offcanvas .bar {
display: inline-block;
position: relative;
width: 20px;
height: 2px;
margin: 8px 0 !important;
background: #fff;
-webkit-transform: rotateZ(0deg) translateX(0px);
-moz-transform: rotateZ(0deg) translateX(0px);
-ms-transform: rotateZ(0deg) translateX(0px);
-o-transform: rotateZ(0deg) translateX(0px);
transform: rotateZ(0deg) translateX(0px);
-webkit-transition: transform 500ms ease-in-out;
-moz-transition: transform 500ms ease-in-out;
-o-transition: transform 500ms ease-in-out;
transition: transform 500ms ease-in-out;
}
header .offcanvas .bar:before {
content: '';
display: block;
position: absolute;
top: 8px;
left: 0;
background: inherit;
width: inherit;
height: inherit;
-webkit-transform: rotateZ(0deg) translateX(0px);
-moz-transform: rotateZ(0deg) translateX(0px);
-ms-transform: rotateZ(0deg) translateX(0px);
-o-transform: rotateZ(0deg) translateX(0px);
transform: rotateZ(0deg) translateX(0px);
-webkit-transition: transform 500ms ease-in-out;
-moz-transition: transform 500ms ease-in-out;
-o-transition: transform 500ms ease-in-out;
transition: transform 500ms ease-in-out;
}
header .offcanvas .bar:after {
content: '';
display: block;
position: absolute;
bottom: 8px;
left: 0;
background: inherit;
width: inherit;
height: inherit;
-webkit-transform: rotateZ(0deg) translateX(0px);
-moz-transform: rotateZ(0deg) translateX(0px);
-ms-transform: rotateZ(0deg) translateX(0px);
-o-transform: rotateZ(0deg) translateX(0px);
transform: rotateZ(0deg) translateX(0px);
-webkit-transition: transform 500ms ease-in-out;
-moz-transition: transform 500ms ease-in-out;
-o-transition: transform 500ms ease-in-out;
transition: transform 500ms ease-in-out;
}
/* Bar Hover */
header .offcanvas:hover .bar {
-webkit-transform: rotateZ(0deg) translateX(-3px);
-moz-transform: rotateZ(0deg) translateX(-3px);
-ms-transform: rotateZ(0deg) translateX(-3px);
-o-transform: rotateZ(0deg) translateX(-3px);
transform: rotateZ(0deg) translateX(-3px);
}
header .offcanvas:hover .bar:before {
-webkit-transform: rotateZ(0deg) translateX(6px);
-moz-transform: rotateZ(0deg) translateX(6px);
-ms-transform: rotateZ(0deg) translateX(6px);
-o-transform: rotateZ(0deg) translateX(6px);
transform: rotateZ(0deg) translateX(6px);
}
header .offcanvas:hover .bar:after {
-webkit-transform: rotateZ(0deg) translateX(6px);
-moz-transform: rotateZ(0deg) translateX(6px);
-ms-transform: rotateZ(0deg) translateX(6px);
-o-transform: rotateZ(0deg) translateX(6px);
transform: rotateZ(0deg) translateX(6px);
}
/* Bar Close */
.uk-offcanvas-page header .offcanvas .bar,
.uk-offcanvas-page header.uk-active .offcanvas .bar {
background: rgba(0, 0, 0, 0);
}
.uk-offcanvas-page header .offcanvas:hover .bar {
-webkit-transform: rotateZ(0deg) translateX(0px);
-moz-transform: rotateZ(0deg) translateX(0px);
-ms-transform: rotateZ(0deg) translateX(0px);
-o-transform: rotateZ(0deg) translateX(0px);
transform: rotateZ(0deg) translateX(0px);
}
.uk-offcanvas-page header .offcanvas .bar:before {
-webkit-transform: rotateZ(45deg) translateX(-11px);
-moz-transform: rotateZ(45deg) translateX(-11px);
-ms-transform: rotateZ(45deg) translateX(-11px);
-o-transform: rotateZ(45deg) translateX(-11px);
transform: rotateZ(45deg) translateX(-11px);
background: #fff;
}
.uk-offcanvas-page header .offcanvas .bar:after {
-webkit-transform: rotateZ(-45deg) translateX(-11px);
-moz-transform: rotateZ(-45deg) translateX(-11px);
-ms-transform: rotateZ(-45deg) translateX(-11px);
-o-transform: rotateZ(-45deg) translateX(-11px);
transform: rotateZ(-45deg) translateX(-11px);
background: #fff;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="center">
<header>
<div class="offcanvas"><i class="bar"></i>
</div>
</header>
</div>
I've slowed down the animations so you can see it skipping, but hover in and out to see it.
I was wondering if anyone more advanced could help me on this one?
Thanks,
Tom
http://jsfiddle.net/xmesop57/
The bounce in effect is jerky in firefox. When I keep refreshing the page, sometimes the effect applies and sometimes it doesn't. But either ways, the bounce in jerky. All fine in chrome though.
There is a huge color difference between chrome and firefox. Why is it. Can this be fixed. My expected color is as seen in firefox.
HTML
<div class="container-fluid">
<div class="row-fluid radial-center">
<div class="centering text-center col-lg-3 clearfix">
<div class="animated bounceInLeft">
<input type="text" class="textbox" id="txtUsername" />
</div>
</div>
</div>
</div>
CSS
.radial-center {
/* fallback */
background-color: #413636;
background-position: center center;
background-repeat: no-repeat;
/* Safari 4-5, Chrome 1-9 */
background: -webkit-gradient(radial, center center, 0, center center, 460, from(#370237), to(#413636));
/* Safari 5.1+, Chrome 10+ */
background: -webkit-radial-gradient(circle, #490338, #121211);
/* Firefox 3.6+ */
background: -moz-radial-gradient(circle, #D52B48, #413636);
/* IE 10 */
background: -ms-radial-gradient(circle, #D52B48, #413636);
}
.animated {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-moz-animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-moz-animation-fill-mode: both;
}
#-webkit-keyframes bounceInLeft {
0% {
opacity: 0;
-webkit-transform: translateX(-2000px);
transform: translateX(-2000px);
}
60% {
opacity: 1;
-webkit-transform: translateX(30px);
transform: translateX(30px);
}
80% {
-webkit-transform: translateX(-10px);
transform: translateX(-10px);
}
100% {
-webkit-transform: translateX(0);
transform: translateX(0);
}
}
#keyframes bounceInLeft {
0% {
opacity: 0;
-webkit-transform: translateX(-2000px);
-ms-transform: translateX(-2000px);
transform: translateX(-2000px);
}
60% {
opacity: 1;
-webkit-transform: translateX(30px);
-ms-transform: translateX(30px);
transform: translateX(30px);
}
80% {
-webkit-transform: translateX(-10px);
-ms-transform: translateX(-10px);
transform: translateX(-10px);
}
100% {
-webkit-transform: translateX(0);
-ms-transform: translateX(0);
transform: translateX(0);
}
}
#-moz-keyframes bounceInLeft {
0% {
opacity: 0;
-webkit-transform: translateX(-2000px);
-ms-transform: translateX(-2000px);
transform: translateX(-2000px);
-moz-transform: translateX(-2000px);
}
60% {
opacity: 1;
-webkit-transform: translateX(30px);
-ms-transform: translateX(30px);
transform: translateX(30px);
-moz-transform: translateX(30px);
}
80% {
-webkit-transform: translateX(-10px);
-ms-transform: translateX(-10px);
transform: translateX(-10px);
-moz-transform: translateX(-10px);
}
100% {
-webkit-transform: translateX(0);
-ms-transform: translateX(0);
transform: translateX(0);
-moz-transform: translateX(0);
}
}
.bounceInLeft {
-webkit-animation-name: bounceInLeft;
animation-name: bounceInLeft;
-moz-animation-name:bounceInLeft;
}
You have two problems. (Those should have been two different questions, really.)
A problem in Firefox is that there's a horizontal scrollbar at one point, which causes the vertical size of the window to change briefly.Solution: give overflow-x:hidden to body.
You don't have the same colours in the -webkit- and -moz- prefixed gradients.Solution: make sure the colours are the same, and/or add an unprefixed radial-gradient after the prefixed ones.
html, body {
height:100%;
margin:0;
padding:0;
overflow-x:hidden; /* here */
}
.container-fluid {
height:100%;
display:table;
width: 100%;
padding:0;
}
.container-fluid:after {
content:none;
}
.container-fluid:before {
content:none;
}
.row-fluid {
height: 100%;
display:table-cell;
vertical-align: middle;
}
.centering {
float:none;
margin:0 auto;
padding:10px;
}
.col-lg-3 {
text-align:center;
}
.radial-center {
/* fallback */
background-color: #413636;
background-position: center center;
background-repeat: no-repeat;
/* Safari 4-5, Chrome 1-9 */
background: -webkit-gradient(radial, center center, 0, center center, 460, from(#D52B48), to(#413636)); /* corrected colours */
/* Safari 5.1+, Chrome 10+ */
background: -webkit-radial-gradient(circle, #D52B48, #413636); /* corrected colours */
/* Firefox 3.6+ */
background: -moz-radial-gradient(circle, #D52B48, #413636);
/* modern browsers */
background: radial-gradient(circle, #D52B48, #413636); /* removed -ms- */
}
.animated {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-moz-animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-moz-animation-fill-mode: both;
}
#-webkit-keyframes bounceInLeft {
0% {
opacity: 0;
-webkit-transform: translateX(-2000px);
transform: translateX(-2000px);
}
60% {
opacity: 1;
-webkit-transform: translateX(30px);
transform: translateX(30px);
}
80% {
-webkit-transform: translateX(-10px);
transform: translateX(-10px);
}
100% {
-webkit-transform: translateX(0);
transform: translateX(0);
}
}
#keyframes bounceInLeft {
0% {
opacity: 0;
-webkit-transform: translateX(-2000px);
-ms-transform: translateX(-2000px);
transform: translateX(-2000px);
}
60% {
opacity: 1;
-webkit-transform: translateX(30px);
-ms-transform: translateX(30px);
transform: translateX(30px);
}
80% {
-webkit-transform: translateX(-10px);
-ms-transform: translateX(-10px);
transform: translateX(-10px);
}
100% {
-webkit-transform: translateX(0);
-ms-transform: translateX(0);
transform: translateX(0);
}
}
#-moz-keyframes bounceInLeft {
0% {
opacity: 0;
-webkit-transform: translateX(-2000px);
-ms-transform: translateX(-2000px);
transform: translateX(-2000px);
-moz-transform: translateX(-2000px);
}
60% {
opacity: 1;
-webkit-transform: translateX(30px);
-ms-transform: translateX(30px);
transform: translateX(30px);
-moz-transform: translateX(30px);
}
80% {
-webkit-transform: translateX(-10px);
-ms-transform: translateX(-10px);
transform: translateX(-10px);
-moz-transform: translateX(-10px);
}
100% {
-webkit-transform: translateX(0);
-ms-transform: translateX(0);
transform: translateX(0);
-moz-transform: translateX(0);
}
}
.bounceInLeft {
-webkit-animation-name: bounceInLeft;
animation-name: bounceInLeft;
-moz-animation-name:bounceInLeft;
}
<div class="container-fluid">
<div class="row-fluid radial-center">
<div class="centering text-center col-lg-3 clearfix">
<div class="animated bounceInLeft">
<input type="text" class="textbox" id="txtUsername" />
</div>
</div>
</div>
</div>
(Or, updated fiddle).
By the way, there is no -ms-radial-gradient.
I'm trying to recreate a negative shake animation, like the Strike uses in their payment box, when there are some form fill errors.
I basically copied it animation keyframe, but in my usage it doesn't work of the same way.
My Version:
http://codepen.io/FelipeMartinin/pen/NGrXvR
Stripe Version:
https://stripe.com/docs/checkout (Click in "Pay with Card" Button and after click in "Pay" without fill the inputs to see the animation)
If you note, the Stripe animation there is a 3d movement effect, and in my version, the box shakes only horizontally. Even with the same keyframe.
Follow in below the keyframe
#keyframes panelShakeAnimation {
0 {
-webkit-transform: translateX(0);
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-o-transform: translateX(0);
transform: translateX(0)
}
12.5% {
-webkit-transform: translateX(-6px) rotateY(-5deg);
-moz-transform: translateX(-6px) rotateY(-5deg);
-ms-transform: translateX(-6px) rotateY(-5deg);
-o-transform: translateX(-6px) rotateY(-5deg);
transform: translateX(-6px) rotateY(-5deg)
}
37.5% {
-webkit-transform: translateX(5px) rotateY(4deg);
-moz-transform: translateX(5px) rotateY(4deg);
-ms-transform: translateX(5px) rotateY(4deg);
-o-transform: translateX(5px) rotateY(4deg);
transform: translateX(5px) rotateY(4deg)
}
62.5% {
-webkit-transform: translateX(-3px) rotateY(-2deg);
-moz-transform: translateX(-3px) rotateY(-2deg);
-ms-transform: translateX(-3px) rotateY(-2deg);
-o-transform: translateX(-3px) rotateY(-2deg);
transform: translateX(-3px) rotateY(-2deg)
}
87.5% {
-webkit-transform: translateX(2px) rotateY(1deg);
-moz-transform: translateX(2px) rotateY(1deg);
-ms-transform: translateX(2px) rotateY(1deg);
-o-transform: translateX(2px) rotateY(1deg);
transform: translateX(2px) rotateY(1deg)
}
100% {
-webkit-transform: translateX(0);
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-o-transform: translateX(0);
transform: translateX(0)
}
}
.headShake {
-webkit-animation-duration: 400ms;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-name: panelShakeAnimation;
-moz-animation-duration: 400ms;
-moz-animation-timing-function: ease-in-out;
-moz-animation-name: panelShakeAnimation
}
How to make my animation works like Stripe? Thanks!
You just need to add a perspective rule on your container element. This makes it so the transformation will appear in 3D space.
Live Demo:
$("button").on('click', function(e) {
e.preventDefault();
$(".card").toggleClass("headShake");
});
/* Basic Reset */
*,
*:after,
*:before {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 62.5%;
}
body {
font-size: 1.8em;
line-height: 1.875;
font-family: "Roboto", sans-serif;
font-weight: 400;
color: #555;
background-color: #eeeeee;
}
/* Basics Styles */
a {
text-decoration: none;
color: #2196f3;
}
h1, h2, h3 {
margin-bottom: 1.2rem;
line-height: 1.5;
}
h1 {
font-size: 4.8rem;
}
h2 {
font-size: 3.2rem;
}
h4 {
font-size: 1.8rem;
font-weight: 300;
}
.lead {
font-size: 1.8rem;
}
p {
margin-bottom: 1.5rem;
}
.main-title {
font-weight: 100;
font-size: 32px;
text-align: center;
}
.main-subtitle {
font-weight: 100;
font-size: 18px;
text-align: center;
}
.text-small {
font-size: 75%;
}
.text-right {
text-align: right;
}
.text-left {
text-align: left;
}
.text-center {
text-align: center;
}
.left {
float: left;
}
.right {
float: right;
}
.display__inline {
display: inline;
}
/* Padding Helpers */
.padding-tb {
padding-top: 3%;
padding-bottom: 3%;
}
/* Basic Demo Styles */
.site-container {
max-width: 320px;
margin: 10px auto;
padding-left: 0.6em;
padding-right: 0.6em;
}
#media screen and (min-width: 60.063em) {
.site-container {
max-width: 400px;
}
}
.footer__content {
margin-top: 1.6rem;
}
/* Card */
.card {
top: 250px;
position: relative;
overflow: hidden;
background-color: white;
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.24), 0 1px 2px 0 rgba(0, 0, 0, 0.12);
border-radius: 2px;
padding: 1em;
}
.card h3 {
font-weight: bold;
}
/* Material Design Form Inputs */
.form__wrapper {
overflow: hidden;
position: relative;
z-index: 1;
display: inline-block;
margin-bottom: 1.6rem;
width: 100%;
vertical-align: top;
}
.form__wrapper--submit {
padding: 1.6rem 0;
}
.form__input {
display: block;
position: relative;
margin-top: 1em;
padding: 0.84em 0;
width: 100%;
box-sizing: border-box;
color: #444;
font-size: 1.6rem;
outline: 0;
border: none;
border-bottom: solid 1px #ddd;
-webkit-transition: all 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);
-moz-transition: all 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);
-o-transition: all 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);
transition: all 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);
background: -webkit-linear-gradient(top, rgba(255, 255, 255, 0) 96%, #2196f3 4%);
background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 96%, #2196f3 4%);
background-position: -400px 0;
background-size: 400px 100%;
background-repeat: no-repeat;
/**
* Remove default box-shadow for required pseudo classes
*/
/**
* When input contain a class of .error
*/
}
.form__input:required {
box-shadow: none;
}
.form__input.error {
-webkit-transition: all 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);
-moz-transition: all 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);
-o-transition: all 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);
transition: all 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);
background: -webkit-linear-gradient(top, rgba(255, 255, 255, 0) 96%, #f44336 4%);
background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 96%, #f44336 4%);
background-position: 0 0;
background-size: 400px 100%;
background-repeat: no-repeat;
}
.form__input:focus {
background-position: 0 0;
color: #444;
-webkit-transition: transform 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);
-moz-transition: transform 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);
-o-transition: transform 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);
transition: transform 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);
}
/* Form Label */
.form__label {
position: absolute;
bottom: 0;
left: 0;
padding: 0;
width: 100%;
height: calc(100% - 1em);
text-align: left;
pointer-events: none;
color: #999;
}
/* Form Label Content */
.form__label-content {
position: absolute;
-webkit-transition: transform 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);
-moz-transition: transform 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);
-o-transition: transform 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);
transition: transform 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);
}
/**
* 1. When input is focused move the label to top
* 2. when the input field has a value move the label to top
*/
.form__input:focus ~ .form__label .form__label-content,
.form--filled .form__label-content {
font-size: 1.4rem;
-webkit-transform: translate3d(0, -65%, 0);
-moz-transform: translate3d(0, -65%, 0);
transform: translate3d(0, -65%, 0);
}
/**
* Error Styles
* .error class generated by jquery.validate.min.js plugin
*/
.error {
font-size: 1.4rem;
color: #f44336;
display: block;
}
/* Basic Buttons */
.btn {
display: inline-block;
padding: 0.6em 1.5em;
border-radius: 2px;
background-color: #2196f3;
color: #fff;
border: 0;
outline: none;
cursor: pointer;
font-family: inherit;
font-weight: 400;
font-size: 1.6rem;
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.24), 0 1px 2px 0 rgba(0, 0, 0, 0.12);
transition: all 0.2s ease;
}
.btn:focus, .btn:hover {
background-color: #0d8aee;
}
.btn.btn-block {
width: 100%;
display: block;
}
/* Modal Styles */
.modal {
overflow: hidden;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #fff;
padding: 1em;
z-index: 999;
border-radius: 2px;
-webkit-transform: translate3d(0, 100%, 0);
-moz-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
-webkit-transition: transform 0.3s cubic-bezier(0, 0.795, 0, 1);
-moz-transition: transform 0.3s cubic-bezier(0, 0.795, 0, 1);
-ms-transition: transform 0.3s cubic-bezier(0, 0.795, 0, 1);
-o-transition: transform 0.3s cubic-bezier(0, 0.795, 0, 1);
transition: transform 0.3s cubic-bezier(0, 0.795, 0, 1);
}
/* Close icon style for model */
.modal--close {
display: block;
float: right;
cursor: pointer;
width: 32px;
height: 32px;
line-height: 32px;
text-align: center;
font-size: 1.6em;
color: #888;
}
.modal--open {
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
#-moz-keyframes panelShakeAnimation {
0 {
-webkit-transform: translateX(0);
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-o-transform: translateX(0);
transform: translateX(0)
}
12.5% {
-webkit-transform: translateX(-6px) rotateY(-5deg);
-moz-transform: translateX(-6px) rotateY(-5deg);
-ms-transform: translateX(-6px) rotateY(-5deg);
-o-transform: translateX(-6px) rotateY(-5deg);
transform: translateX(-6px) rotateY(-5deg)
}
37.5% {
-webkit-transform: translateX(5px) rotateY(4deg);
-moz-transform: translateX(5px) rotateY(4deg);
-ms-transform: translateX(5px) rotateY(4deg);
-o-transform: translateX(5px) rotateY(4deg);
transform: translateX(5px) rotateY(4deg)
}
62.5% {
-webkit-transform: translateX(-3px) rotateY(-2deg);
-moz-transform: translateX(-3px) rotateY(-2deg);
-ms-transform: translateX(-3px) rotateY(-2deg);
-o-transform: translateX(-3px) rotateY(-2deg);
transform: translateX(-3px) rotateY(-2deg)
}
87.5% {
-webkit-transform: translateX(2px) rotateY(1deg);
-moz-transform: translateX(2px) rotateY(1deg);
-ms-transform: translateX(2px) rotateY(1deg);
-o-transform: translateX(2px) rotateY(1deg);
transform: translateX(2px) rotateY(1deg)
}
100% {
-webkit-transform: translateX(0);
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-o-transform: translateX(0);
transform: translateX(0)
}
}
#-webkit-keyframes panelShakeAnimation {
0 {
-webkit-transform: translateX(0);
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-o-transform: translateX(0);
transform: translateX(0)
}
12.5% {
-webkit-transform: translateX(-6px) rotateY(-5deg);
-moz-transform: translateX(-6px) rotateY(-5deg);
-ms-transform: translateX(-6px) rotateY(-5deg);
-o-transform: translateX(-6px) rotateY(-5deg);
transform: translateX(-6px) rotateY(-5deg)
}
37.5% {
-webkit-transform: translateX(5px) rotateY(4deg);
-moz-transform: translateX(5px) rotateY(4deg);
-ms-transform: translateX(5px) rotateY(4deg);
-o-transform: translateX(5px) rotateY(4deg);
transform: translateX(5px) rotateY(4deg)
}
62.5% {
-webkit-transform: translateX(-3px) rotateY(-2deg);
-moz-transform: translateX(-3px) rotateY(-2deg);
-ms-transform: translateX(-3px) rotateY(-2deg);
-o-transform: translateX(-3px) rotateY(-2deg);
transform: translateX(-3px) rotateY(-2deg)
}
87.5% {
-webkit-transform: translateX(2px) rotateY(1deg);
-moz-transform: translateX(2px) rotateY(1deg);
-ms-transform: translateX(2px) rotateY(1deg);
-o-transform: translateX(2px) rotateY(1deg);
transform: translateX(2px) rotateY(1deg)
}
100% {
-webkit-transform: translateX(0);
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-o-transform: translateX(0);
transform: translateX(0)
}
}
#-o-keyframes panelShakeAnimation {
0 {
-webkit-transform: translateX(0);
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-o-transform: translateX(0);
transform: translateX(0)
}
12.5% {
-webkit-transform: translateX(-6px) rotateY(-5deg);
-moz-transform: translateX(-6px) rotateY(-5deg);
-ms-transform: translateX(-6px) rotateY(-5deg);
-o-transform: translateX(-6px) rotateY(-5deg);
transform: translateX(-6px) rotateY(-5deg)
}
37.5% {
-webkit-transform: translateX(5px) rotateY(4deg);
-moz-transform: translateX(5px) rotateY(4deg);
-ms-transform: translateX(5px) rotateY(4deg);
-o-transform: translateX(5px) rotateY(4deg);
transform: translateX(5px) rotateY(4deg)
}
62.5% {
-webkit-transform: translateX(-3px) rotateY(-2deg);
-moz-transform: translateX(-3px) rotateY(-2deg);
-ms-transform: translateX(-3px) rotateY(-2deg);
-o-transform: translateX(-3px) rotateY(-2deg);
transform: translateX(-3px) rotateY(-2deg)
}
87.5% {
-webkit-transform: translateX(2px) rotateY(1deg);
-moz-transform: translateX(2px) rotateY(1deg);
-ms-transform: translateX(2px) rotateY(1deg);
-o-transform: translateX(2px) rotateY(1deg);
transform: translateX(2px) rotateY(1deg)
}
100% {
-webkit-transform: translateX(0);
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-o-transform: translateX(0);
transform: translateX(0)
}
}
#-ms-keyframes panelShakeAnimation {
0 {
-webkit-transform: translateX(0);
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-o-transform: translateX(0);
transform: translateX(0)
}
12.5% {
-webkit-transform: translateX(-6px) rotateY(-5deg);
-moz-transform: translateX(-6px) rotateY(-5deg);
-ms-transform: translateX(-6px) rotateY(-5deg);
-o-transform: translateX(-6px) rotateY(-5deg);
transform: translateX(-6px) rotateY(-5deg)
}
37.5% {
-webkit-transform: translateX(5px) rotateY(4deg);
-moz-transform: translateX(5px) rotateY(4deg);
-ms-transform: translateX(5px) rotateY(4deg);
-o-transform: translateX(5px) rotateY(4deg);
transform: translateX(5px) rotateY(4deg)
}
62.5% {
-webkit-transform: translateX(-3px) rotateY(-2deg);
-moz-transform: translateX(-3px) rotateY(-2deg);
-ms-transform: translateX(-3px) rotateY(-2deg);
-o-transform: translateX(-3px) rotateY(-2deg);
transform: translateX(-3px) rotateY(-2deg)
}
87.5% {
-webkit-transform: translateX(2px) rotateY(1deg);
-moz-transform: translateX(2px) rotateY(1deg);
-ms-transform: translateX(2px) rotateY(1deg);
-o-transform: translateX(2px) rotateY(1deg);
transform: translateX(2px) rotateY(1deg)
}
100% {
-webkit-transform: translateX(0);
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-o-transform: translateX(0);
transform: translateX(0)
}
}
#keyframes panelShakeAnimation {
0 {
-webkit-transform: translateX(0);
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-o-transform: translateX(0);
transform: translateX(0)
}
12.5% {
-webkit-transform: translateX(-6px) rotateY(-5deg);
-moz-transform: translateX(-6px) rotateY(-5deg);
-ms-transform: translateX(-6px) rotateY(-5deg);
-o-transform: translateX(-6px) rotateY(-5deg);
transform: translateX(-6px) rotateY(-5deg)
}
37.5% {
-webkit-transform: translateX(5px) rotateY(4deg);
-moz-transform: translateX(5px) rotateY(4deg);
-ms-transform: translateX(5px) rotateY(4deg);
-o-transform: translateX(5px) rotateY(4deg);
transform: translateX(5px) rotateY(4deg)
}
62.5% {
-webkit-transform: translateX(-3px) rotateY(-2deg);
-moz-transform: translateX(-3px) rotateY(-2deg);
-ms-transform: translateX(-3px) rotateY(-2deg);
-o-transform: translateX(-3px) rotateY(-2deg);
transform: translateX(-3px) rotateY(-2deg)
}
87.5% {
-webkit-transform: translateX(2px) rotateY(1deg);
-moz-transform: translateX(2px) rotateY(1deg);
-ms-transform: translateX(2px) rotateY(1deg);
-o-transform: translateX(2px) rotateY(1deg);
transform: translateX(2px) rotateY(1deg)
}
100% {
-webkit-transform: translateX(0);
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-o-transform: translateX(0);
transform: translateX(0)
}
}
.headShake {
-webkit-animation-duration: 400ms;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-name: panelShakeAnimation;
-moz-animation-duration: 400ms;
-moz-animation-timing-function: ease-in-out;
-moz-animation-name: panelShakeAnimation;
}
.site-container {
-webkit-perspective: 800px;
perspective: 800px;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h1 class="main-title">Head Shake Animation</h1>
<h2 class="main-subtitle">An amazing animation for negative feedbacks</h2>
<section class="site-container padding-tb">
<section class="card" style="opacity: 1; transition: none; transform: translateY(0px) scale(1); margin-top: -244px;">
<h3 >Login Form</h3>
<form action="#" class="form" method="post">
<div class="form__wrapper">
<input type="email" class="form__input" id="email" name="email">
<label class="form__label" for="email">
<span class="form__label-content">Email</span>
</label>
</div>
<div class="form__wrapper">
<input type="password" class="form__input" id="password" name="password">
<label class="form__label" for="password">
<span class="form__label-content">Password</span>
</label>
</div>
<div class="form__wrapper--submit">
<div class="form__input-submit">
<button class="btn btn-block">Submit to run</button>
</div>
</div>
</form>
</section><!-- /card -->
</section><!-- /site-container -->
Add perspective to the container, to get the 3-d effect
.site-container {
max-width: 320px;
margin: 10px auto;
padding-left: 0.6em;
padding-right: 0.6em;
perspective: 400px;
}
I have rounded submit btn, that I want to scale to 80% from the start and when I hover it I want it to scale to 100% and also rotate 360 degrees. Here's the code, I haven't have any luck finding any answers on the web.
header #searchbtn{
background: url(../img/roundedsearchbtn.png) no-repeat;
border: 0;
cursor: pointer;
display: inline-block;
float: right;
height: 41px;
filter: alpha(opacity=60);
opacity: 0.60;
-webkit-transition: all 0.3s linear;
-moz-transition: all 0.3s linear;
-o-transition: all 0.3s linear;
transition: all 0.3s linear;
overflow: hidden;
text-indent: 100%;
width: 41px;
-webkit-transform: scale(0.8);
-moz-transform: scale(0.8);
-ms-transform: scale(0.8);
-o-transform: scale(0.8);
-transform: scale(0.8);
}
header #searchbtn:hover, header #searchbtn:focus {
filter: alpha(opacity=100);
opacity: 1;
-webkit-transform: rotate(360deg) scale(1);
-moz-transform: rotate(360deg) scale(1);
-ms-transform: rotate(360deg) scale(1);
-o-transform: rotate(360deg) scale(1);
-transform: rotate(360deg) scale(1);
}
This is what you want? Fiddle
Just add these CSS rules:
button {
-webkit-transform: rotate(0) scale(.8,.8);
-moz-transform: rotate(0) scale(.8,.8);
transform: rotate(0) scale(.8,.8);
}
button:hover {
-webkit-transform: rotate(360deg) scale(1,1);
-moz-transform: rotate(360deg) scale(1,1);
transform: rotate(360deg) scale(1,1);
}