I'm currently trying to create a blinking eye effect with HTML and CSS. My problem is that the under part (eyelid) is moving the wrong way. It should be animated counterwise in order to look like the desired effect.
I already tired a lot of things to make it work and don't have any idea what else to do.
Here's my CSS. Is this a problem where some JS is needed as well?
.upper-eye {
background: linear-gradient(to bottom,
rgb(0, 0, 0),
rgba(255,255,255, 0) 10%);
width: 100%;
height: 300%;
z-index: 0;
position: fixed;
top:0;
left:0;
animation: bounce 2s linear infinite;
}
.under-eye {
background: linear-gradient(to top,
rgb(0, 0, 0),
rgba(255,255,255, 0) 10%);
width: 100%;
height: 300%;
z-index: 100;
position: fixed;
bottom: -10px;
left: 0;
animation: bounce 2s linear infinite;
}
#-webkit-keyframes bounce {
0%, 20%, 50%, 80%, 100% {-webkit-transform: translateY(0);}
40% {-webkit-transform: translateY(-30px);}
60% {-webkit-transform: translateY(-15px);}
}
#keyframes bounce {
0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
40% {transform: translateY(-30px);}
60% {transform: translateY(-15px);}
}
.bounce {
-webkit-animation-name: bounce;
animation-name: bounce;
}
The problem is that you're using the same #keyframes and expecting a different action. You might need to make a second #keyframes setting to do what you want but the other way around, then you could set that #keyframes to the bottom eyelid.
So it could look something like this:
#-webkit-keyframes bounceReverse {
0%, 20%, 50%, 80%, 100% {-webkit-transform: translateY(0);}
40% {-webkit-transform: translateY(-15px);}
60% {-webkit-transform: translateY(-30px);}
}
keyframes bounceReverse {
0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
40% {transform: translateY(-15px);}
60% {transform: translateY(-30px);}
}
bounceReverse {
webkit-animation-name: bounceReverse;
animation-name: bounceReverse;
}
You could also try using animation-direction: reverse; on the existing #keyframes animation to reverse the effect of the keyframe you're seeing correctly on the top eyelid.
Animation of falling drops works perfectly in firefox browser, but in chrome and edge does not work.
The animation works by hovering the mouse over a spot.
In firefox, you can see that these drops are a liquid that extends.
In other browsers, it is a circle that drops down.
I added animations and keyframes to compatible all browsers, it did not help.
In addition to this, the position of the droplets also changes.
Thank you for any help and best regards
body
{
background-color:#5c5c5c;
height:1100px;
}
#drip
{
position: absolute;
}
.path-choose
{
pointer-events: none;
position: absolute;
left: 20%;
}
.crop
{
position: absolute;
-webkit-clip-path: polygon(99% 30%, 97% 18%, 91% 13%, 86% 13%, 82% 15%, 77% 17%, 72% 19%, 68% 19%, 63% 17%, 58% 11%, 54% 8%, 49% 10%, 44% 15%, 39% 21%, 35% 24%, 30% 25%, 26% 22%, 21% 14%, 17% 8%, 12% 3%, 8% 1%, 3% 4%, 1% 15%, 1% 25%, 2% 34%, 5% 41%, 8% 45%, 11% 52%, 11% 62%, 12% 72%, 14% 81%, 17% 86%, 21% 88%, 26% 88%, 30% 84%, 34% 82%, 37% 81%, 42% 84%, 46% 88%, 50% 92%, 54% 95%, 57% 97%, 61% 98%, 65% 95%, 68% 89%, 71% 84%, 75% 84%, 79% 84%, 83% 84%, 87% 80%, 87% 70%, 87% 61%, 89% 54%, 93% 49%, 96% 44%, 99% 39%);
clip-path: polygon(99% 30%, 97% 18%, 91% 13%, 86% 13%, 82% 15%, 77% 17%, 72% 19%, 68% 19%, 63% 17%, 58% 11%, 54% 8%, 49% 10%, 44% 15%, 39% 21%, 35% 24%, 30% 25%, 26% 22%, 21% 14%, 17% 8%, 12% 3%, 8% 1%, 3% 4%, 1% 15%, 1% 25%, 2% 34%, 5% 41%, 8% 45%, 11% 52%, 11% 62%, 12% 72%, 14% 81%, 17% 86%, 21% 88%, 26% 88%, 30% 84%, 34% 82%, 37% 81%, 42% 84%, 46% 88%, 50% 92%, 54% 95%, 57% 97%, 61% 98%, 65% 95%, 68% 89%, 71% 84%, 75% 84%, 79% 84%, 83% 84%, 87% 80%, 87% 70%, 87% 61%, 89% 54%, 93% 49%, 96% 44%, 99% 39%);
z-index: 3;
pointer-events: auto;
}
.view
{
position: absolute;
z-index: 100;
pointer-events: none;
-webkit-user-select: none;
user-select: none;
}
#keyframes fade-in {0% {opacity: 0;}100% {opacity: 1;}}
#keyframes drop {0% {bottom: 0px;opacity: 1;}80% {opacity: 1;}100% {opacity: 1;bottom: -200px;}}
#keyframes wave {0% {background-position: 0 160px;background-size: 170px 300px;}100% {background-position: 500px -18px;background-size: 250px 150px;}}
.drops {
-webkit-filter: url('#liquid');
filter: url('#liquid');
-moz-filter: url('#liquid');
-o-filter: url('#liquid');
-ms-filter: url('#liquid');
position:relative;
top:0;
left:5px;
bottom:0;
right:0;
z-index: 1;
opacity: 0;
animation: fade-in .1s linear .4s forwards;
-moz-animation: fade-in .1s linear .4s forwards;
-webkit-animation: fade-in .1s linear .4s forwards;
-o-animation: fade-in .1s linear .4s forwards;
-ms-animation: fade-in .1s linear .4s forwards;
animation-delay: 1.5s;
width: 120px;
height: 120px;
line-height: 120px;
margin: auto;
}
.drops2 {
-webkit-filter: url('#liquid');
filter: url('#liquid');
-moz-filter: url('#liquid');
-o-filter: url('#liquid');
-ms-filter: url('#liquid');
position:relative;
top:-97px;
left:145px;
bottom:0;
right:0;
z-index: 1;
opacity: 0;
animation: fade-in .1s linear .4s forwards;
-moz-animation: fade-in .1s linear .4s forwards;
-webkit-animation: fade-in .1s linear .4s forwards;
-o-animation: fade-in .1s linear .4s forwards;
-ms-animation: fade-in .1s linear .4s forwards;
line-height: 120px;
width: 120px;
height: 120px;
margin: auto;
}
.drops3 {
-webkit-filter: url('#liquid');
filter: url('#liquid');
-moz-filter: url('#liquid');
-o-filter: url('#liquid');
-ms-filter: url('#liquid');
position:relative;
top:-240px;
left:230px;
bottom:0;
right:0;
z-index: 1;
opacity: 0;
animation: fade-in .1s linear .4s forwards;
-moz-animation: fade-in .1s linear .4s forwards;
-webkit-animation: fade-in .1s linear .4s forwards;
-o-animation: fade-in .1s linear .4s forwards;
-ms-animation: fade-in .1s linear .4s forwards;
line-height: 120px;
width: 120px;
height: 120px;
margin: auto;
}
.drop1 {
width: 60px;
height: 16px;
bottom: 2px;
border-radius: 0;
}
.drop2 {
animation: drop 1.3s cubic-bezier(1,.19,.66,.12) .5s infinite;
-moz-animation: drop 1.3s cubic-bezier(1,.19,.66,.12) .5s infinite;
-webkit-animation: drop 1.3s cubic-bezier(1,.19,.66,.12) .5s infinite;
-o-animation: drop 1.3s cubic-bezier(1,.19,.66,.12) .5s infinite;
-ms-animation: drop 1.3s cubic-bezier(1,.19,.66,.12) .5s infinite;
}
.drop3 {
animation: drop 1.6s cubic-bezier(1,.19,.66,.12) .5s infinite;
-moz-animation: drop 1.6s cubic-bezier(1,.19,.66,.12) .5s infinite;
-webkit-animation: drop 1.6s cubic-bezier(1,.19,.66,.12) .5s infinite;
-o-animation: drop 1.6s cubic-bezier(1,.19,.66,.12) .5s infinite;
-ms-animation: drop 1.6s cubic-bezier(1,.19,.66,.12) .5s infinite;
}
.drop4 {
animation: drop 1.47s cubic-bezier(1,.19,.66,.12) .5s infinite;
-moz-animation: drop 1.47s cubic-bezier(1,.19,.66,.12) .5s infinite;
-webkit-animation: drop 1.47s cubic-bezier(1,.19,.66,.12) .5s infinite;
-o-animation: drop 1.47s cubic-bezier(1,.19,.66,.12) .5s infinite;
-ms-animation: drop 1.47s cubic-bezier(1,.19,.66,.12) .5s infinite;
}
.drop1 , .drop2, .drop3, .drop4 {
width: 21px;
height: 24px;
border-radius: 50%;
position: absolute;
left: 0;
right: 0;
bottom: 0;
margin: auto;
background-color: #ffc476;
}
.drop2,.drop3,.drop4 /*,.drops, .drops2,.drops3 */
{
animation-play-state: paused;
display:none;
}
.display:hover .drop2,.display:hover .drop3,.display:hover .drop4,.display:hover .drops,.display:hover .drops2,.display:hover .drops3{
animation-play-state: running;
display:block;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Candle Wax</title>
<meta name="keywords" content="Candle">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<div class="path-choose">
<img src="https://i.stack.imgur.com/0oSu6.png" width="343px" height="142px" class="view">
<div class="display">
<img src="https://i.stack.imgur.com/0oSu6.png" width="343px" height="142px" class="crop" ondragstart="return false;">
<div id="drip">
<div class="drops">
<div class="drop1"></div>
<div class="drop2"></div>
</div>
<div class="drops2">
<div class="drop1"></div>
<div class="drop3"></div>
</div>
<div class="drops3">
<div class="drop1"></div>
<div class="drop4"></div>
</div>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs>
<filter id="liquid">
<feGaussianBlur in="SourceGraphic" stdDeviation="10" result="blur" />
<feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -7" result="liquid" />
</filter>
</defs>
</svg>
</div>
</div>
</div>
</body>
</html>
The red box appeared in the middle of its containter when the page first load then moving from left to right and reappear like this image:
Here's what i did so far but it does not suit the idea above:
.box{
-webkit-animation: left-to-right 10s infinite; /* Chrome, Safari, Opera */
animation: left-to-right 10s infinite;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes left-to-right {
100%{
left:-1000px
}
}
#keyframes left-to-right {
100%{
left:-1000px
}
}
Page width is 1280px and box width is 1000px.
You can use this:
http://codepen.io/anon/pen/dPEJzm
<div id="animated-example" class="animated shake"></div>
.animated {
-webkit-animation-duration: 5s;
animation-duration: 5s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-timing-function: linear;
animation-timing-function: linear;
animation-iteration-count:infinite;
-webkit-animation-iteration-count:infinite;
}
#-webkit-keyframes shake {
0%, 100% {-webkit-transform: translateX(0);}
10%, 30%, 50%, 70%, 90% {-webkit-transform: translateX(-50px);}
20%, 40%, 60%, 80% {-webkit-transform: translateX(50px);}
}
#keyframes shake {
0%, 100% {transform: translateX(0);}
10%, 30%, 50%, 70%, 90% {transform: translateX(-50px);}
20%, 40%, 60%, 80% {transform: translateX(50px);}
}
.shake {
-webkit-animation-name: shake;
animation-name: shake;
}
.shake {
background:red;
height:100px;
width:100px;
}
http://jsfiddle.net/bvjzmke5/3/
I make it complete in 2s and used -50% to move, change that however you want.
.box{
-webkit-animation: right-to-left 2s linear infinite; /* Chrome, Safari, Opera */
animation: right-to-left 2s linear infinite;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes right-to-left {
100%{
left:-50%
}
}
#keyframes left-to-right {
100%{
left:-50%
}
}
.square{
-webkit-animation: left-to-right 2s linear infinite; /* Chrome, Safari, Opera */
animation: left-to-right 2s linear infinite;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes left-to-right {
100%{
right:-50%
}
}
#keyframes left-to-right {
100%{
right:-50%
}
}
<div id="container" style="height:100px; width:60%; margin:0 auto">
<div class="box" style="height:100px; width:50%;background:red;position:relative;display:inline-block"></div>
<div class="square" style="height:100px; width:100px; background:red;position:relative;display:inline-block"></div>
</div>
I want to make a div a little fuzzy adding this css class
.fuzz{
margin-left: 0px;
animation:fuzz 0.1s linear 0s infinite ;
-moz-animation: fuzz 0.1s linear 0s infinite ; /* Firefox */
-webkit-animation: fuzz 0.1s linear 0s infinite ; /* Safari and Chrome */
-o-animation: fuzz 0.1s linear 0s infinite ; /* Opera */
}
#keyframes fuzz
{
0% {margin-left: 0px; transform: rotate(5deg);}
25% {margin-left: -5px; transform: rotate(-5deg);}
50% {margin-left: 0px; transform: rotate(0deg);}
75% {margin-left: 5px; transform: rotate(5deg);}
100% {margin-left: 0px; transform: rotate(0deg);}
}
#-moz-keyframes fuzz /* Firefox */
{
0% {margin-left: 0px; transform: rotate(5deg);}
25% {margin-left: -5px; transform: rotate(-5deg);}
50% {margin-left: 0px; transform: rotate(0deg);}
75% {margin-left: 5px; transform: rotate(5deg);}
100% {margin-left: 0px; transform: rotate(0deg);}
}
#-webkit-keyframes fuzz /* Safari and Chrome */
{
0% {margin-left: 0px; transform: rotate(5deg);}
25% {margin-left: -5px; transform: rotate(-5deg);}
50% {margin-left: 0px; transform: rotate(0deg);}
75% {margin-left: 5px; transform: rotate(5deg);}
100% {margin-left: 0px; transform: rotate(0deg);}
}
#-o-keyframes fuzz /* Opera */
{
0% {margin-left: 0px; transform: rotate(5deg);}
25% {margin-left: -5px; transform: rotate(-5deg);}
50% {margin-left: 0px; transform: rotate(0deg);}
75% {margin-left: 5px; transform: rotate(5deg);}
100% {margin-left: 0px; transform: rotate(0deg);}
}
but it only shake left and right...
Why transform: rotate(5deg) doesn't work?
How can i do?
best practice and performance
Demo: http://jsfiddle.net/4X6Dt/3/
.fuzz{
animation:fuzz 0.1s linear 0s infinite ;
-moz-animation: fuzz 0.1s linear 0s infinite ; /* Firefox */
-webkit-animation: fuzz 0.1s linear 0s infinite ; /* Safari and Chrome */
-o-animation: fuzz 0.1s linear 0s infinite ; /* Opera */
backface-visibility:hidden;
-webkit-backface-visibility:hidden; /* Chrome and Safari */
-moz-backface-visibility:hidden; /* Firefox */
-ms-backface-visibility:hidden; /* Internet Explorer */
}
#keyframes fuzz
{
0% {transform: rotate(5deg) translate3d( 0px,0,0);}
25% {transform: rotate(-5deg) translate3d( -5px,0,0);}
50% {transform: rotate(0deg) translate3d( 0px,0,0);}
75% {transform: rotate(5deg) translate3d( 5px,0,0);}
100% {transform: rotate(0deg) translate3d( 0px,0,0);}
}
#-moz-keyframes fuzz /* Firefox */
{
0% {-moz-transform: rotate(5deg) translate3d( 0px,0,0);}
25% {-moz-transform: rotate(-5deg) translate3d( -5px,0,0);}
50% {-moz-transform: rotate(0deg) translate3d( 0px,0,0);}
75% {-moz-transform: rotate(5deg) translate3d( 5px,0,0);}
100% {-moz-transform: rotate(0deg) translate3d( 0px,0,0);}
}
#-webkit-keyframes fuzz /* Safari and Chrome */
{
0% {-webkit-transform: rotate(5deg) translate3d( 0px,0,0);}
25% {-webkit-transform: rotate(-5deg) translate3d( -5px,0,0);}
50% {-webkit-transform: rotate(0deg) translate3d( 0px,0,0);}
75% {-webkit-transform: rotate(5deg) translate3d( 5px,0,0);}
100% {-webkit-transform: rotate(0deg) translate3d( 0px,0,0);}
}
#-o-keyframes fuzz /* Opera */
{
0% {-o-transform: rotate(5deg) translate3d( 0px,0,0);}
25% {-o-transform: rotate(-5deg) translate3d( -5px,0,0);}
50% {-o-transform: rotate(0deg) translate3d( 0px,0,0);}
75% {-o-transform: rotate(5deg) translate3d( 5px,0,0);}
100% {-o-transform: rotate(0deg) translate3d( 0px,0,0);}
}
I have a simple CSS animation to fade in text:
#title{
animation: text 2s;
-webkit-animation: text 2s;
-moz-animation: text 2s;
-o-animation: text 2s;
font-family: 'Lato300', sans-serif;
height: 115px;
position: absolute;
bottom: -10px;
left: 0;
right: 0;
margin-bottom: auto;
margin-left: auto;
margin-right: auto;
text-align: center;
}
#keyframes text{
0% {display: none;}
100% {display: inline;}
}
#-moz-keyframes text{
0% {display: none;}
100% {display: inline;}
}
#-webkit-keyframes text{
0% {display: none;}
100% {display: inline;}
}
#-o-keyframes text{
0% {display: none;}
100% {display: inline;}
}
The HTML:
<div id="title"><h1>Text goes here</h1></div>
For some reason, the animation doesn't play. Does anyone know why?
(I kept all the code incase something else is causing the problem)
You will not be able to animate display property. However you can transition an opacity
#-webkit-keyframes text {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
http://jsfiddle.net/5FCZA/
shake
#-webkit-keyframes text {
0%, 100% {-webkit-transform: translateX(0);}
10%, 30%, 50%, 70%, 90% {-webkit-transform: translateX(-10px);}
20%, 40%, 60%, 80% {-webkit-transform: translateX(10px);}
}
or rotate
#-webkit-keyframes text {
0% {-webkit-transform: scale(1);}
10%, 20% {-webkit-transform: scale(0.9) rotate(-3deg);}
30%, 50%, 70%, 90% {-webkit-transform: scale(1.1) rotate(3deg);}
40%, 60%, 80% {-webkit-transform: scale(1.1) rotate(-3deg);}
100% {-webkit-transform: scale(1) rotate(0);}
}
For anyone in the future experiencing a similar issue I solved this by adding
display:block
to the span I was trying to animate