Understanding how a candle flame is created in a simple SVG - html

I was just looking at a simple SVG cake animation HERE , the CSS code looks like so:
#import url(http://fonts.googleapis.com/css?family=Lato:300italic);
html,
body {
width: 100%;
height: 100%;
}
body {
background: #ee9ca7;
}
#cake {
display: block;
position: relative;
margin: -10em auto 0 auto;
}
*/* ============================================== Candle
*/
.velas {
background: #ffffff;
border-radius: 10px;
position: absolute;
top: 228px;
left: 50%;
margin-left: -2.4px;
margin-top: -8.33333333px;
width: 5px;
height: 35px;
transform: translateY(-300px);
backface-visibility: hidden;
animation: in 500ms 6s ease-out forwards;
}
.velas:after,
.velas:before {
background: rgba(255, 0, 0, 0.4);
content: "";
position: absolute;
width: 100%;
height: 2.22222222px;
}
.velas:after {
top: 25%;
left: 0;
}
.velas:before {
top: 45%;
left: 0;
}
/* ============================================== Fire
*/
.fuego {
border-radius: 100%;
position: absolute;
top: -20px;
left: 50%;
margin-left: -2.6px;
width: 6.66666667px;
height: 18px;
}
.fuego:nth-child(1) {
animation: fuego 2s 6.5s infinite;
}
.fuego:nth-child(2) {
animation: fuego 1.5s 6.5s infinite;
}
.fuego:nth-child(3) {
animation: fuego 1s 6.5s infinite;
}
.fuego:nth-child(4) {
animation: fuego 0.5s 6.5s infinite;
}
.fuego:nth-child(5) {
animation: fuego 0.2s 6.5s infinite;
}
/* ============================================== Animation Fire
*/
#keyframes fuego {
0%, 100% {
background: rgba(254, 248, 97, 0.5);
box-shadow: 0 0 40px 10px rgba(248, 233, 209, 0.2);
transform: translateY(0) scale(1);
}
50% {
background: rgba(255, 50, 0, 0.1);
box-shadow: 0 0 40px 20px rgba(248, 233, 209, 0.2);
transform: translateY(-20px) scale(0);
}
}
#keyframes in {
to {
transform: translateY(0);
}
}
.text {
color: #8b6a60;
font-family: 'Lato', sans-serif;
font-weight: 300;
font-style:italic;
text-align: center;
h1 {
font-size: 1.4em;
}
}
After inspecting the code a bit i came to know the candle flame was caused by this set of HTML elements:
<div class="velas">
<div class="fuego"></div>
<div class="fuego"></div>
<div class="fuego"></div>
<div class="fuego"></div>
<div class="fuego"></div>
</div>
And this HTML has the following CSS code:
background: #ffffff;
border-radius: 10px;
position: absolute;
top: 228px;
left: 50%;
margin-left: -2.4px;
margin-top: -8.33333333px;
width: 5px;
height: 35px;
transform: translateY(-300px);
backface-visibility: hidden;
animation: in 500ms 6s ease-out forwards;
}
.velas:after,
.velas:before {
background: rgba(255, 0, 0, 0.4);
content: "";
position: absolute;
width: 100%;
height: 2.22222222px;
}
.velas:after {
top: 25%;
left: 0;
}
.velas:before {
top: 45%;
left: 0;
}
/* ============================================== Fire
*/
.fuego {
border-radius: 100%;
position: absolute;
top: -20px;
left: 50%;
margin-left: -2.6px;
width: 6.66666667px;
height: 18px;
}
.fuego:nth-child(1) {
animation: fuego 2s 6.5s infinite;
}
.fuego:nth-child(2) {
animation: fuego 1.5s 6.5s infinite;
}
.fuego:nth-child(3) {
animation: fuego 1s 6.5s infinite;
}
.fuego:nth-child(4) {
animation: fuego 0.5s 6.5s infinite;
}
.fuego:nth-child(5) {
animation: fuego 0.2s 6.5s infinite;
}
/* ============================================== Animation Fire
*/
#keyframes fuego {
0%, 100% {
background: rgba(254, 248, 97, 0.5);
box-shadow: 0 0 40px 10px rgba(248, 233, 209, 0.2);
transform: translateY(0) scale(1);
}
50% {
background: rgba(255, 50, 0, 0.1);
box-shadow: 0 0 40px 20px rgba(248, 233, 209, 0.2);
transform: translateY(-20px) scale(0);
}
}
#keyframes in {
to {
transform: translateY(0);
}
}
Now i don't see the CSS code that is actually cauing the red and yellow flame , i beleive the white shadow is caused by the very high box shadow given in the animations , but somehow i don't see where the candle flame is created , can somebody guide me as to where the candle flame is really created ?

The colors are set by RGB values. There's a yellow, red, and some pink.
#keyframes fuego {
0%, 100% {
background: rgba(254, 248, 97, 0.5); /* yellow */
box-shadow: 0 0 40px 10px rgba(248, 233, 209, 0.2); /* pink */
transform: translateY(0) scale(1);
}
50% {
background: rgba(255, 50, 0, 0.1); /* red */
box-shadow: 0 0 40px 20px rgba(248, 233, 209, 0.2); /* pink again */
transform: translateY(-20px) scale(0);
}
}
Timings to change the colors are set in .fuego:nth-child(1) through .fuego:nth-child(6)

Related

How do I sync css animations? or even put it together?

My problem is that I want to loop the animation but I don't know how to solve it. i tried to use animation infinite unfortunately i couldn't solve the problem so i would contact you if you can help with this. The code would be the loading screen of a website. I want the animation to go on all the time. So how can this be solved?
#keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
#keyframes toXCenter {
to {
transform: translateX(-50%);
}
}
#keyframes toFullHeight {
to {
height: 100%;
}
}
body {
background-color: #ffffff;
font-family: 'Montserrat', sans-serif;
}
.icon {
animation: fadeIn 1.4s cubic-bezier(0.25, 0.54, 0.31, 0.995) 0.8s 1 forwards, fadeOut 1.4s cubic-bezier(0.25, 0.54, 0.31, 0.995) 7s 1 forwards;
background-color: rgba(0, 0, 0, 0.05);
border-radius: 50%;
height: 220px;
left: 50%;
opacity: 0;
overflow: hidden;
position: absolute;
top: 50%;
transform: translateX(-50%) translateY(-50%);
width: 220px;
}
.icon__content {
animation: moveDown 2s cubic-bezier(0.25, 0.54, 0.31, 0.995) 6s 1 forwards;
height: 100%;
position: relative;
width: 100%;
}
#keyframes moveDown {
to {
transform: translateY(100%);
}
}
.icon__finger {
animation: toXCenter 2s cubic-bezier(0.25, 0.54, 0.31, 0.995) 1.2s 1 forwards;
background-color: #FFCC80;
border-radius: 50px 50px 0 0;
bottom: 0;
content: "";
height: 136px;
left: 50%;
overflow: hidden;
position: absolute;
right: 0;
transform: translateX(-50%) translateY(200px);
width: 95px;
z-index: 1;
}
.icon__finger:before {
background-color: rgba(0, 0, 0, 0.025);
content: "";
height: 100%;
position: absolute;
right: 0;
width: 50%;
z-index: -1;
}
.icon__finger:after {
background-color: rgba(0, 0, 0, 0.1);
border-radius: 0 0 50px 50px;
content: "";
height: 70px;
left: 15px;
position: absolute;
right: 15px;
top: 0;
}
.icon__nail {
animation: toXCenter 2s cubic-bezier(0.25, 0.54, 0.31, 0.995) 1.2s 1 forwards;
background-color: rgba(255, 255, 255, 0.8);
border-radius: 20px 20px 50px 50px;
bottom: 75px;
content: "";
height: 110px;
left: 50%;
overflow: hidden;
position: absolute;
right: 0;
transform: translateX(-50%) translateY(200px);
width: 60px;
z-index: 2;
}
.icon__nail:before {
animation: toFullHeight 1.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) 2.2s 1 forwards;
background-color: #FFFFFF;
border-radius: 0 0 50px 50px;
bottom: 0;
content: "";
height: 0%;
position: absolute;
width: 100%;
z-index: 3;
}
.icon__nail:after {
animation: toFullHeight 1.4s cubic-bezier(0.25, 0.54, 0.31, 0.995) 3.6s 1 forwards, colours 4s cubic-bezier(0.25, 0.54, 0.31, 0.995) 0s infinite alternate;
background-color: #F50057;
border-radius: 0 0 50px 50px;
bottom: 0;
content: "";
height: 0%;
position: absolute;
width: 100%;
z-index: 3;
}
#keyframes colours {
0% {
background-color: #E91E63;
}
50% {
background-color: #9C27B0;
}
100% {
background-color: #2196F3;
}
}
.nail__gloss {
border-radius: 0 0 20px;
bottom: 12px;
height: 100px;
overflow: hidden;
position: absolute;
right: 10px;
width: 26px;
z-index: 4;
}
.nail__gloss:before {
animation: toFullHeight 1.2s cubic-bezier(0.435, 0.715, 0.355, 0.595) 4.6s 1 forwards;
background-color: rgba(255, 255, 255, 0.5);
bottom: 0;
content: "";
height: 0%;
position: absolute;
right: 0;
width: 50%;
}
<div class="icon">
<div class="icon__content">
<div class="icon__nail">
<div class="nail__gloss"></div>
</div>
<div class="icon__finger">
</div>
</div>
</div>
https://codepen.io/drelaky/pen/LYybLMQ
I calculated the total animation time and it came to be about 8s. I have two answers for you:
Change the content of loader to restart the animation:
setInterval(() => {
let loader = document.querySelector("#loader");
let icon = loader.innerHTML;
loader.innerHTML = "";
loader.innerHTML = icon;
}, 8000);
#keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
#keyframes toXCenter {
to {
transform: translateX(-50%);
}
}
#keyframes toFullHeight {
to {
height: 100%;
}
}
body {
background-color: rgb(58, 58, 58);
}
.icon {
animation: fadeIn 1.4s cubic-bezier(0.25, 0.54, 0.31, 0.995) 0.8s 1 forwards, fadeOut 1.4s cubic-bezier(0.25, 0.54, 0.31, 0.995) 7s 1 forwards;
background-color: rgba(0, 0, 0, 0.05);
border-radius: 50%;
height: 220px;
left: 50%;
opacity: 0;
overflow: hidden;
position: absolute;
top: 50%;
transform: translateX(-50%) translateY(-50%);
width: 220px;
}
.icon__content {
animation: moveDown 2s cubic-bezier(0.25, 0.54, 0.31, 0.995) 6s 1 forwards;
height: 100%;
position: relative;
width: 100%;
}
#keyframes moveDown {
to {
transform: translateY(100%);
}
}
.icon__finger {
animation: toXCenter 2s cubic-bezier(0.25, 0.54, 0.31, 0.995) 1.2s 1 forwards;
background-color: #FFCC80;
border-radius: 50px 50px 0 0;
bottom: 0;
content: "";
height: 136px;
left: 50%;
overflow: hidden;
position: absolute;
right: 0;
transform: translateX(-50%) translateY(200px);
width: 95px;
z-index: 1;
}
.icon__finger:before {
background-color: rgba(0, 0, 0, 0.025);
content: "";
height: 100%;
position: absolute;
right: 0;
width: 50%;
z-index: -1;
}
.icon__finger:after {
background-color: rgba(0, 0, 0, 0.1);
border-radius: 0 0 50px 50px;
content: "";
height: 70px;
left: 15px;
position: absolute;
right: 15px;
top: 0;
}
.icon__nail {
animation: toXCenter 2s cubic-bezier(0.25, 0.54, 0.31, 0.995) 1.2s 1 forwards;
background-color: rgba(255, 255, 255, 0.8);
border-radius: 20px 20px 50px 50px;
bottom: 75px;
content: "";
height: 110px;
left: 50%;
overflow: hidden;
position: absolute;
right: 0;
transform: translateX(-50%) translateY(200px);
width: 60px;
z-index: 2;
}
.icon__nail:before {
animation: toFullHeight 1.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) 2.2s 1 forwards;
background-color: #FFFFFF;
border-radius: 0 0 50px 50px;
bottom: 0;
content: "";
height: 0%;
position: absolute;
width: 100%;
z-index: 3;
}
.icon__nail:after {
animation: toFullHeight 1.4s cubic-bezier(0.25, 0.54, 0.31, 0.995) 3.6s 1 forwards, colours 4s cubic-bezier(0.25, 0.54, 0.31, 0.995) 0s infinite alternate;
background-color: #F50057;
border-radius: 0 0 50px 50px;
bottom: 0;
content: "";
height: 0%;
position: absolute;
width: 100%;
z-index: 3;
}
#keyframes colours {
0% {
background-color: #E91E63;
}
50% {
background-color: #9C27B0;
}
100% {
background-color: #2196F3;
}
}
.nail__gloss {
border-radius: 0 0 20px;
bottom: 12px;
height: 100px;
overflow: hidden;
position: absolute;
right: 10px;
width: 26px;
z-index: 4;
}
.nail__gloss:before {
animation: toFullHeight 1.2s cubic-bezier(0.435, 0.715, 0.355, 0.595) 4.6s 1 forwards;
background-color: rgba(255, 255, 255, 0.5);
bottom: 0;
content: "";
height: 0%;
position: absolute;
right: 0;
width: 50%;
}
<div id='loader'>
<div class="icon">
<div class="icon__content">
<div class="icon__nail">
<div class="nail__gloss"></div>
</div>
<div class="icon__finger">
</div>
</div>
</div>
</div>
Record it using a screen recorder, convert it into gif and use it on the website. This will take less time and energy of the browser to render the loader.

Hide overflow in a position relative container

I have a problem, I made a beautiful button with snake effect but I need a last thing, I need to hide overflow to make the snake effect.
there is my button:
I want to hide theses parts, with overflow: hidden; this works with position: absolute; but not with relative.
body {
padding: 30px;
}
.btn-order {
position: relative;;
background-color: #961a22;
color: #ff7675;
padding: 30px 60px;
font-family: Helvetica;
font-size: 30px;
font-weight: 400;
letter-spacing: 2px;
text-transform: uppercase;
text-decoration: none;
box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
overflow: hidden;
}
.btn-order:before {
content: '';
position: absolute;
top: 0px;
left: 0px;
bottom: 0px;
width: 50%;
background: rgba(255, 255, 255, 0.07);
}
.btn-order span:nth-child(1) {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 4px;
background: linear-gradient(to right, #ffffff, #ff3a3a);
animation: animate1 1.25s linear infinite;
}
#keyframes animate1 {
0% {
transform: translateX(-100%);
}
100% {
transform: translateX(100%);
}
}
.btn-order span:nth-child(2) {
position: absolute;
top: 0;
right: 0;
width: 4px;
height: 100%;
background: linear-gradient(to bottom, #ffffff, #ff3a3a);
animation: animate2 1.25s linear infinite;
animation-delay: 0.625s;
}
#keyframes animate2 {
0% {
transform: translateY(-100%);
}
100% {
transform: translateY(100%);
}
}
.btn-order span:nth-child(3) {
position: absolute;
bottom: 0;
right: 0;
width: 100%;
height: 4px;
background: linear-gradient(to left, #ffffff, #ff3a3a);
animation: animate3 1.25s linear infinite;
}
#keyframes animate3 {
0% {
transform: translateX(100%);
}
100% {
transform: translateX(-100%);
}
}
.btn-order span:nth-child(4) {
position: absolute;
top: 0;
left: 0;
width: 4px;
height: 100%;
background: linear-gradient(to top, #ffffff, #ff3a3a);
animation: animate4 1.25s linear infinite;
animation-delay: 0.625s;
}
#keyframes animate4 {
0% {
transform: translateY(100%);
}
100% {
transform: translateY(-100%);
}
}
<a href="#" class="btn-order">
<span></span>
<span></span>
<span></span>
<span></span>
COMMANDER
</a>
Thanks for helping me :)
Increasing the body width can fix it.

box-shadow animation in safari not fading

I have this animation working in Chrome and Android, while in Safari and iOS rings are not fading away but staying black. What is causing that?
Is there way not to use box-shadow and achieve same effect?
https://codepen.io/anon/pen/oVZWQa
<div class="loader">
<span class="ring ring-1"></span>
<span class="ring ring-2"></span>
<span class="ring ring-3"></span>
<span class="ring ring-4"></span>
</div>
#yellow: #FFD200;
#brown: darken(#yellow, 45%);
body {
background: fade(#yellow, 90%);
}
.loader {
position: relative;
width: 20rem;
height: 20rem;
.ring {
position: absolute;
border-radius: 50%;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
animation: pulse 8s ease-out infinite;
&.ring-2 {
animation-delay: 2000ms
}
&.ring-3 {
animation-delay: 4000ms
}
&.ring-4 {
animation-delay: 6000ms
}
}
#keyframes pulse {
0% {
box-shadow: 0 0 0 60px #brown;
transform: scale(0);
opacity: 0;
}
25% {
box-shadow: 0 0 0 45px rgba(darken(#yellow, 40%), 0.66);
opacity: 1;
}
50% {
box-shadow: 0 0 0 25px rgba(darken(#yellow, 30%) 0.33);
}
100% {
box-shadow: 0 0 0 1px rgba(darken(#yellow, 20%) 0);
transform: scale(1);
}
}
}
as #Turnip pointed out I had missing commas.

Simple line animation with keyframes

I tried to make a smooth animation, but the animate has a sort of "cut bug" in the middle.
How can I fix it ?
div,
div:after {
width: 0vw;
height: 3px;
position: fixed;
top: 1vw; bottom: 0;
left: 40vw; right: 40vw;
margin: auto;
/* margin-top: -16px;*/
z-index: 600;
background-color: rgba(0, 0, 0, 1);
}
div {
/*background-color: transparent;*/
/* border-top: 3px solid rgba(0, 0, 0, 0.1);
border-right: 3px solid rgba(0, 0, 0, 0.1);
border-bottom: 3px solid rgba(0, 0, 0, 0.1);
border-left: 3px solid black;
-webkit-transform: translateZ(0);
transform: translateZ(0);*/
-webkit-animation-iteration-count:infinite;
animation-iteration-count:infinite;
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
-webkit-animation-direction: alternate;
animation-direction: alternate;
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-name: animsition-loading;
animation-name: animsition-loading;
}
#-webkit-keyframes animsition-loading {
0% {
/*width: 0vw;*/
transform:translate(0vw);
width :0vw;
margin-left: 0;
}
50% {
/*width: 0vw;*/
/*transform:translate(5vw);*/
width :10vw;
}
100% {
/*width: 0vw;*/
transform:translate(1vw);
width :0vw;
margin-right: 0;
}
}
<div> </div>
Here is another way to achieve the same with less of code:
.loading {
height: 3px;
position: fixed;
top: 2vw;
left: 40vw;
right: 40vw;
height: 3px;
background: linear-gradient(#000, #000) left/0% 100% no-repeat;
animation: anime 2s ease-in-out infinite alternate;
}
#keyframes anime {
0% {
background-size: 0% 100%;
background-position: left;
}
50% {
background-size: 70% 100%;
}
100% {
background-size: 0% 100%;
background-position: right;
}
}
<div class="loading"></div>
Try setting your animation this way:
#-webkit-keyframes animsition-loading {
0% {
width :0;
left: 0;
}
50% {
width :10vw;
}
100% {
width :0;
right: 0;
}
Is that the effect you are looking for?
Try this and you're done...
Don't use transform translate, use only width instead.
div,
div:after {
width: 0vw;
height: 3px;
position: fixed;
top: 1vw; bottom: 0;
left: 40vw; right: 40vw;
margin: auto;
/* margin-top: -16px;*/
z-index: 600;
background-color: rgba(0, 0, 0, 1);
}
div {
/*background-color: transparent;*/
/* border-top: 3px solid rgba(0, 0, 0, 0.1);
border-right: 3px solid rgba(0, 0, 0, 0.1);
border-bottom: 3px solid rgba(0, 0, 0, 0.1);
border-left: 3px solid black;
-webkit-transform: translateZ(0);
transform: translateZ(0);*/
-webkit-animation-iteration-count:infinite;
animation-iteration-count:infinite;
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
-webkit-animation-direction: alternate;
animation-direction: alternate;
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-name: animsition-loading;
animation-name: animsition-loading;
}
#-webkit-keyframes animsition-loading {
0% {
width :0;
left: 0;
}
50% {
width :10vw;
}
100% {
width :0;
right: 0;
}
}
<div> </div>

button div not clickable only work if I click on text tried everything nothing works

I try to create hover animation button but I don't know why it's not working when I click on div only works if I click on their text even I write display:block in anchor tag.
Below is my html and css code also jsfiddle.
Html :
<div class="animation-button">
<div class="raised hoverable">
<div class="anim"></div><span>More About Us</span>
</div>
</div>
Css :
.animation-button .raised {
position: relative;
margin: 1em;
font-weight: 100;
padding: 10px 19px;
text-align: center;
//min-width:14%;
/*width: 200px;*/
/*border-radius: 5px;*/
overflow: hidden;
position: relative;
z-index: 0;
cursor: pointer;
display: inline-block;
}
.animation-button .raised {
-moz-transition: all 0.1s;
-o-transition: all 0.1s;
-webkit-transition: all 0.1s;
transition: all 0.1s;
background: #849C8E;
box-shadow: 0px 1px 1px #849C8E;
}
.animation-button .raised:active {
background: #70897A;
box-shadow: 0px 1px 1px #70897A;
/* display: inline-block; */
}
.animation-button .raised span a {
font-weight: 400;
font-size: 3vw;
color: #fff;
text-decoration: none;
display: block;
}
.animation-button span a:hover,#ankur span a:focus{
color: #fff;
display: block;
}
.anim {
-moz-transform: translateY(-50%) translateX(-50%);
-ms-transform: translateY(-50%) translateX(-50%);
-webkit-transform: translateY(-50%) translateX(-50%);
transform: translateY(-50%) translateX(-50%);
position: absolute;
top: 50%;
left: 50%;
z-index: -1;
}
.anim:before {
position: relative;
content: '';
display: block;
margin-top: 100%;
}
.anim:after {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border-radius: 50%;
}
.hoverable:hover > .anim {
-moz-animation: anim-out 0.75s;
-webkit-animation: anim-out 0.75s;
animation: anim-out 0.75s;
}
.hoverable:hover > .anim:after {
-moz-animation: anim-out-pseudo 0.75s;
-webkit-animation: anim-out-pseudo 0.75s;
animation: anim-out-pseudo 0.75s;
}
#-webkit-keyframes anim-in {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#-moz-keyframes anim-in {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#-ms-keyframes anim-in {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#keyframes anim-in {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#-webkit-keyframes anim-in-pseudo {
0% {
background: rgba(0, 0, 0, 0.25);
}
100% {
background: transparent;
}
}
#-moz-keyframes anim-in-pseudo {
0% {
background: rgba(0, 0, 0, 0.25);
}
100% {
background: transparent;
}
}
#-ms-keyframes anim-in-pseudo {
0% {
background: rgba(0, 0, 0, 0.25);
}
100% {
background: transparent;
}
}
#keyframes anim-in-pseudo {
0% {
background: rgba(0, 0, 0, 0.25);
}
100% {
background: transparent;
}
}
#-webkit-keyframes anim-out {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#-moz-keyframes anim-out {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#-ms-keyframes anim-out {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#keyframes anim-out {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#-webkit-keyframes anim-out-pseudo {
0% {
background: rgba(0, 0, 0, 0.25);
}
100% {
background: transparent;
}
}
#-moz-keyframes anim-out-pseudo {
0% {
background: rgba(0, 0, 0, 0.25);
}
100% {
background: transparent;
}
}
#-ms-keyframes anim-out-pseudo {
0% {
background: rgba(0, 0, 0, 0.25);
}
100% {
background: transparent;
}
}
#keyframes anim-out-pseudo {
0% {
background: rgba(0, 0, 0, 0.25);
}
100% {
background: transparent;
}
}
jsfiddle : https://jsfiddle.net/a2zgk/yL8ngrx5/1/
Add the padding to the a tag instead of the button so that the link cover the whole area of the button like this :
.animation-button .raised {
position: relative;
margin: 1em;
font-weight: 100;
text-align: center;
//min-width:14%;
/*width: 200px;*/
/*border-radius: 5px;*/
overflow: hidden;
position: relative;
z-index: 0;
cursor: pointer;
display: inline-block;
}
.animation-button .raised {
-moz-transition: all 0.1s;
-o-transition: all 0.1s;
-webkit-transition: all 0.1s;
transition: all 0.1s;
background: #849C8E;
box-shadow: 0px 1px 1px #849C8E;
}
.animation-button .raised:active {
background: #70897A;
box-shadow: 0px 1px 1px #70897A;
/* display: inline-block; */
}
.animation-button .raised span a {
font-weight: 400;
font-size: 3vw;
color: #fff;
text-decoration: none;
display: block;
padding: 10px 19px;
}
.animation-button span a:hover,
#ankur span a:focus {
color: #fff;
display: block;
}
.anim {
-moz-transform: translateY(-50%) translateX(-50%);
-ms-transform: translateY(-50%) translateX(-50%);
-webkit-transform: translateY(-50%) translateX(-50%);
transform: translateY(-50%) translateX(-50%);
position: absolute;
top: 50%;
left: 50%;
z-index: -1;
}
.anim:before {
position: relative;
content: '';
display: block;
margin-top: 100%;
}
.anim:after {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border-radius: 50%;
}
.hoverable:hover>.anim {
-moz-animation: anim-out 0.75s;
-webkit-animation: anim-out 0.75s;
animation: anim-out 0.75s;
}
.hoverable:hover>.anim:after {
-moz-animation: anim-out-pseudo 0.75s;
-webkit-animation: anim-out-pseudo 0.75s;
animation: anim-out-pseudo 0.75s;
}
#-webkit-keyframes anim-in {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#-moz-keyframes anim-in {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#-ms-keyframes anim-in {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#keyframes anim-in {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#-webkit-keyframes anim-in-pseudo {
0% {
background: rgba(0, 0, 0, 0.25);
}
100% {
background: transparent;
}
}
#-moz-keyframes anim-in-pseudo {
0% {
background: rgba(0, 0, 0, 0.25);
}
100% {
background: transparent;
}
}
#-ms-keyframes anim-in-pseudo {
0% {
background: rgba(0, 0, 0, 0.25);
}
100% {
background: transparent;
}
}
#keyframes anim-in-pseudo {
0% {
background: rgba(0, 0, 0, 0.25);
}
100% {
background: transparent;
}
}
#-webkit-keyframes anim-out {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#-moz-keyframes anim-out {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#-ms-keyframes anim-out {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#keyframes anim-out {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#-webkit-keyframes anim-out-pseudo {
0% {
background: rgba(0, 0, 0, 0.25);
}
100% {
background: transparent;
}
}
#-moz-keyframes anim-out-pseudo {
0% {
background: rgba(0, 0, 0, 0.25);
}
100% {
background: transparent;
}
}
#-ms-keyframes anim-out-pseudo {
0% {
background: rgba(0, 0, 0, 0.25);
}
100% {
background: transparent;
}
}
#keyframes anim-out-pseudo {
0% {
background: rgba(0, 0, 0, 0.25);
}
100% {
background: transparent;
}
}
<div class="animation-button">
<div class="raised hoverable">
<div class="anim"></div><span>More About Us</span>
</div>
</div>