I tried every trick I could find but still, the animation is jerky.
I tried following some advice on another question where it was advised to use transition instead of keyframes but it seems that with transition only I'd need to use Javascript which I want to avoid.
Here is the snippet:
/* ////////////////// TOP NAV BAR GRID //////////////// */
.grid-container-topnav {
position: absolute;
top: 1px;
left: 1px;
width: 290px;
display: inline-grid;
width: 0px;
gap: 0px;
padding: 0px;
grid-template-columns: repeat(4, minmax(69px, 69px)) 14px;
grid-template-rows: 32px;
}
.grid-item-topnav {
border-top-left-radius: 5px;
border-top-right-radius: 5px;
font-size: 16px;
font-family: Candara Light, Cascadia Code, Courier New, monospace;
border: solid 1px #272727;
color: #e4e4e4;
overflow: hidden;
opacity: 0;
}
.topnav-item1 {
grid-column: 1;
grid-row: 1;
}
.topnav-item2 {
grid-column: 2;
grid-row: 1;
}
.topnav-item3 {
grid-column: 3;
grid-row: 1;
}
.topnav-item4 {
grid-column: 4;
grid-row: 1;
}
.topnav-item1,
.topnav-item2,
.topnav-item3,
.topnav-item4{
background: linear-gradient(0deg, #303030, transparent) #505050;
animation-duration: 0.2s;
transition: 0.2s ease-in-out;
}
.topnav-item1:hover,
.topnav-item2:hover,
.topnav-item3:hover,
.topnav-item4:hover{
-webkit-box-shadow: inset 0 5px 5px rgba(0, 0, 0, .075), 0 0 5px #6461ff;
-webkit-transition: 0.25s ease-out;
display: inline;
border: solid 1px #6461ff;
background-color: #6968a7;
}
.topnav-item1:active,
.topnav-item2:active,
.topnav-item3:active,
.topnav-item4:active{
-webkit-box-shadow: inset 1px 1px 5px #00000013, 1px 1px 8px #e9666699;
-webkit-transition: 0.25s ease-out;
display: inline;
border: solid 1px #e63f3f;
background-color: #6e6e6e;
}
.topnav-item5 {
top:0px;
grid-column: 5;
grid-row: 1;
font-family: Arial;
animation-duration: 0.2s;
transition: 0.2s ease-in-out;
color: #cccccc;
background-color: #9b1e1e;
}
.topnav-item5:hover {
-webkit-box-shadow: inset 0 5px 5px rgba(0, 0, 0, .075), 0 0 5px #c71e1e;
border: solid 1px #c71e1e;
color: #ffffff00;
background-color: #9b1e1e;
}
.active_tab {
outline: 0;
-webkit-transition: 0.25s ease-out;
display: inline;
background-color: #6968a7;
}
/* /////// - ONLOAD ANIMATION > CHILD SUBGRID ITEMS - /////// */
.j05 { position: relative; left: 25px; top: -20px; animation: scale-in-item 2s 0s ease-in-out forwards; }
.j04 { position: relative; left: 25px; top: -20px; animation: scale-in-item 2s 0.1s ease-in-out forwards; }
.j03 { position: relative; left: 25px; top: -20px; animation: scale-in-item 2s 0.2s ease-in-out forwards; }
.j02 { position: relative; left: 25px; top: -20px; animation: scale-in-item 2s 0.3s ease-in-out forwards; }
.j01 { position: relative; left: 25px; top: -20px; animation: scale-in-item 2s 0.4s ease-in-out forwards; }
#-webkit-keyframes scale-in-item {
0% {
opacity: 0;
transform: perspective(0px) scale3d(0.1, 0.1, 1) translateZ(0px);
}
100% {
top: 0px;
left:0px;
opacity: 1;
transform: perspective(0px) scale3d(1, 1, 1) translateZ(0px);
}
}
.no-flickr {
-webkit-transform: translateZ(0);
-webkit-backface-visibility: hidden;
-webkit-perspective: 1000;
-webkit-transform-style: preserve-3d;
}
<div class="grid-container-topnav">
<button class="grid-item-topnav topnav-item1 no-flickr j01" id="myItem1" tabindex="-1">Banana</button>
<button class="grid-item-topnav topnav-item2 no-flickr j02" id="myItem2" tabindex="-1">Apples</button>
<button class="grid-item-topnav topnav-item3 no-flickr j03" id="myItem3" tabindex="-1">Oranges</button>
<button class="grid-item-topnav topnav-item4 no-flickr j04" id="myItem4" tabindex="-1">Kiwis</button>
<button class="grid-item-topnav topnav-item5 no-flickr j05" id="myItemX" tabindex="-1"></button>
</div>
As user #JHeth suggested, I added the position values to the #Keyframes.
transform: perspective(0px) translate3d(-50px, 15px, 0px) translateZ(0px);
It worked. Now the animation is smooth like silk.
Related
i have my link that was styled, but when I change link tag to button in html and css styling won't work. How can get that styling on button type submit note I can't get link to submit via js because of interference with stripe that's why i wanna get this one working
a styling that is working
a.animated-button:link:after, a.animated-button:visited:after {
content: "";
position: absolute;
height: 0%;
left: 50%;
top: 0;
width: 150%;
z-index: -1;
-webkit-transition: all 0.75s ease 0s;
-moz-transition: all 0.75s ease 0s;
-o-transition: all 0.75s ease 0s;
transition: all 0.75s ease 0s;
}
a.animated-button:link:hover, a.animated-button:visited:hover {
color: #FFF;
text-shadow: none;
}
a.animated-button:link:hover:after, a.animated-button:visited:hover:after {
height: 450%;
}
a.animated-button:link, a.animated-button:visited {
position: relative;
display: block;
margin: 0px auto 0;
padding: 14px 15px;
color: #fff;
font-size:12px;
border-radius: 0;
font-weight: bold;
text-align: center;
text-decoration: none;
text-transform: uppercase;
overflow: hidden;
letter-spacing: .08em;
text-shadow: 0 0 1px rgba(0, 0, 0, 0.2), 0 1px 0 rgba(0, 0, 0, 0.2);
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
a.animated-button.thar-three {
color: rgb(68, 68, 68);
cursor: pointer;
display: block;
position: relative;
border: 1px solid #dddddd;
transition: all 0.4s cubic-bezier(0.42, 0, 0.58, 1);
}
a.animated-button.thar-three:hover {
color: #000 !important;
background-color: transparent;
text-shadow: nthree;
}
a.animated-button.thar-three:hover:before {
left: 0%;
right: auto;
width: 100%;
}
a.animated-button.thar-three:before {
display: block;
position: absolute;
top: 0px;
right: 0px;
height: 100%;
width: 0px;
z-index: -1;
content: '';
color: #000 !important;
background: #f5f5f5;
transition: all 0.4s cubic-bezier(0.42, 0, 0.58, 1);
}
{% trans "pay" %}
button styling that won't work
button[type=submit].animated-button:link:after, button[type=submit].animated-button:visited:after {
content: "";
position: absolute;
height: 0%;
left: 50%;
top: 0;
width: 150%;
z-index: -1;
-webkit-transition: all 0.75s ease 0s;
-moz-transition: all 0.75s ease 0s;
-o-transition: all 0.75s ease 0s;
transition: all 0.75s ease 0s;
}
button[type=submit].animated-button:link:hover, button[type=submit].animated-button:visited:hover {
color: #FFF;
text-shadow: none;
}
button[type=submit].animated-button:link:hover:after, button[type=submit].animated-button:visited:hover:after {
height: 450%;
}
button[type=submit].animated-button:link, button[type=submit].animated-button:visited {
position: relative;
display: block;
margin: 0px auto 0;
padding: 14px 15px;
color: #fff;
font-size:12px;
border-radius: 0;
font-weight: bold;
text-align: center;
text-decoration: none;
text-transform: uppercase;
overflow: hidden;
letter-spacing: .08em;
text-shadow: 0 0 1px rgba(0, 0, 0, 0.2), 0 1px 0 rgba(0, 0, 0, 0.2);
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
button[type=submit].animated-button.thar-three {
color: rgb(68, 68, 68);
cursor: pointer;
display: block;
position: relative;
border: 1px solid #dddddd;
transition: all 0.4s cubic-bezier(0.42, 0, 0.58, 1);
}
button[type=submit].animated-button.thar-three:hover {
color: #000 !important;
background-color: transparent;
text-shadow: nthree;
}
button[type=submit].animated-button.thar-three:hover:before {
left: 0%;
right: auto;
width: 100%;
}
button[type=submit].animated-button.thar-three:before {
display: block;
position: absolute;
top: 0px;
right: 0px;
height: 100%;
width: 0px;
z-index: -1;
content: '';
color: #000 !important;
background: #f5f5f5;
transition: all 0.4s cubic-bezier(0.42, 0, 0.58, 1);
}
<button type="submit" href="" class="btn btn-sm animated-button thar-three">{% trans "pay" %}</button>
since a div is not a link, you can't use the selectors :link nor :visited. By simply removing them from your css, the result is way closer. Of course, you may have to implement a method to replace the use of :link and :visited
button[type=submit].animated-button:after, button[type=submit].animated-button:after {
content: "";
position: absolute;
height: 0%;
left: 50%;
top: 0;
width: 100%;
z-index: -1;
-webkit-transition: all 0.75s ease 0s;
-moz-transition: all 0.75s ease 0s;
-o-transition: all 0.75s ease 0s;
transition: all 0.75s ease 0s;
}
button[type=submit].animated-button:hover, button[type=submit].animated-button:hover {
color: #FFF;
text-shadow: none;
}
button[type=submit].animated-button:hover:after, button[type=submit].animated-button:hover:after {
height: 450%;
}
button[type=submit].animated-button, button[type=submit].animated-button {
position: relative;
display: block;
margin: 0px auto 0;
padding: 14px 15px;
color: #fff;
font-size:12px;
border-radius: 0;
font-weight: bold;
text-align: center;
text-decoration: none;
text-transform: uppercase;
overflow: hidden;
letter-spacing: .08em;
text-shadow: 0 0 1px rgba(0, 0, 0, 0.2), 0 1px 0 rgba(0, 0, 0, 0.2);
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
button[type=submit].animated-button.thar-three {
color: rgb(68, 68, 68);
cursor: pointer;
display: block;
position: relative;
border: 1px solid #dddddd;
transition: all 0.4s cubic-bezier(0.42, 0, 0.58, 1);
}
button[type=submit].animated-button.thar-three:hover {
color: #000 !important;
background-color: transparent;
text-shadow: nthree;
}
button[type=submit].animated-button.thar-three:hover:before {
left: 0%;
right: auto;
width: 100%;
}
button[type=submit].animated-button.thar-three:before {
display: block;
position: absolute;
top: 0px;
right: 0px;
height: 100%;
width: 0px;
z-index: -1;
content: '';
color: #000 !important;
background: #f5f5f5;
transition: all 0.4s cubic-bezier(0.42, 0, 0.58, 1);
}
<button type="submit" href="" class="btn btn-sm animated-button thar-three">{% trans "pay" %}</button>
I have a hover animation that I have created with CSS. When the user hovers over the link the underline transitions from left to right changing the colour from black to grey. Currently as you would expect when the user moves their mouse off the link the transition reverses to start state.
I wondered if it is possible to prevent this reverse transition and instead fade the underline back to the colour black (the original start state)?
Here is a jsfiddle to work with.
Any suggestions/advise would be most welcome.
a.btn--tertiary {
padding-left: 0;
padding-right: 0;
background-color: transparent;
color: #000;
border: 0;
position: relative;
padding-bottom: 5px;
text-transform: uppercase;
text-decoration: none;
font-size: 40px;
}
.btn--tertiary:before {
content: '';
height: 2px;
right: 0;
width: 100%;
background: #000;
position: absolute;
bottom: 0;
opacity: 1;
transition: width 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) 0s;
z-index: 2;
border-left: 10px solid transparent;
}
.btn--tertiary:after {
content: '';
height: 2px;
left: 0;
right: auto;
width: 0%;
background: grey;
position: absolute;
bottom: 0;
transition: width 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) 0.1s;
z-index: 3;
}
.btn--tertiary:hover:before,
.btn--tertiary:focus:before {
width: 0%;
border-left: 20px solid $white;
}
.btn--tertiary:hover::after,
.btn--tertiary:focus::after {
right: 0;
width: 100%;
}
Yes, it is indeed. The trick is to make the width transition out take 0s with a delay of 1s.
html,
body {
margin: 0;
padding: 0;
}
a.btn--tertiary {
padding-left: 0;
padding-right: 0;
background-color: transparent;
color: #000;
border: 0;
position: relative;
padding-bottom: 5px;
text-transform: uppercase;
text-decoration: none;
font-size: 40px;
}
.btn--tertiary::before {
content: '';
height: 2px;
right: 0;
width: 100%;
background: #000;
position: absolute;
bottom: 0;
transition: width 0s;
z-index: 2;
border-left: 10px solid transparent;
}
.btn--tertiary::after {
content: '';
height: 2px;
left: 0;
right: auto;
width: 0%;
background: grey;
position: absolute;
bottom: 0;
opacity: 0;
transition: opacity .5s, width 0s .5s;
z-index: 3;
}
.btn--tertiary:hover:before,
.btn--tertiary:focus:before {
width: 0%;
border-left: 20px solid $white;
transition: width 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) 0s;
}
.btn--tertiary:hover::after,
.btn--tertiary:focus::after {
right: 0;
width: 100%;
opacity: 1;
transition: opacity 0s, width 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) 0.1s;
}
Button
Fiddle.
You can try like below. Check the comments for the details:
a.btn--tertiary {
color: #000;
position: relative;
padding-bottom: 5px;
display:inline-block;
text-decoration:none;
overflow:hidden;
font-size: 40px;
}
.btn--tertiary:before,
.btn--tertiary:after {
content: '';
height: 2px;
position: absolute;
bottom: 0;
}
.btn--tertiary:before {
right: 0;
width: 100%;
background: #000;
border-left: 20px solid #fff;
transition:
background 2s cubic-bezier(0.100, 0.600, 0.350, 1.000); /* transition the background on mouseout*/
}
.btn--tertiary:after {
left: 0;
width: 0%;
background: red;
}
.btn--tertiary:hover:before,
.btn--tertiary:focus:before {
width: 0%;
background: red;
transition:
width 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) 0s, /* visible transition of width on hover */
background 0s 1s; /* no transition but a background change after 1s */
}
.btn--tertiary:hover::after,
.btn--tertiary:focus::after {
right: 0;
width: 100%;
transition:
width 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) 0.1s; /* visible transition of width on hover */
}
Button
I hope this would help, please see the example below.
div {
text-align: center;
margin-top: 20px;
}
.btn--tertiary {
text-decoration: none;
font-family: sans-serif;
text-transform: uppercase;
display: inline-block;
position: relative;
overflow: hidden;
font-size: 45px;
color: black;
}
.btn--tertiary::before {
position: absolute;
content: '';
width: 100%;
height: 3px;
bottom: 0;
left: 0;
background: gray;
transform: scale(0, 1);
transform-origin: right;
transition: transform 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) 0s;
}
.btn--tertiary:hover::before {
transform: scale(1, 1);
transform-origin: left;
transition: transform 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) .1s;
}
.btn--tertiary::after {
position: absolute;
content: '';
width: 100%;
height: 3px;
bottom: 0;
right: 0;
background: black;
transform: scale(1, 1);
transform-origin: left;
transition: transform 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) .1s;
}
.btn--tertiary:hover::after {
transform: scale(0, 1);
transform-origin: right;
transition: transform 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) 0s;
}
<div>
Button
</div>
I just want to make a preloader that's positioned in the middle of the page.
Requirements:
position: fixed;
centered on the X-axis
It's just a div with class 'preloader' in body. Body is this div's direct parent, no other wrapper in between.
.preloader {
position: fixed;
display: inline-block;
z-index: 99;
top: 45%;
left: 50%;
width: 60px;
height: 60px;
-ms-transform: translateX(100px); /*100px just to test if it moved at all, initially had -50%, see list below*/
-webkit-transform: translateX(100px);
transform: translateX(100px);
//=====rest is just animation and aesthetics======
border: 3px solid #8A2EE6;
border-radius: 50%;
border-bottom: 3px solid black;
box-shadow: 0px 0px 20px 1px rgba(153, 102, 255, 0.5) inset, 0px 0px 20px 1px rgba(153, 102, 255, 0.5);
animation-name: rotatePreloader;
animation-duration: 0.65s;
animation-direction: normal;
animation-iteration-count: infinite;
animation-timing-function: linear;
transition: opacity 1s;
}
I've done:
display: block;
display: inline-block;
translateX(-50%);
translateX(30px);
translate(-50%, 0);
translate(30px, 0);
translate(-50%, -50%);
rearranging the transforms.. lol
took off -o & -mos
margin: 0 auto (worked with position: relative when I didn't need it to be fixed)
https://jsfiddle.net/goa3v2ke/#
You need to do like this, where you set top/left to 50% and then move them back with translate using the same value, int this case -50%.
Sample 1 now center it both horizontal and vertical, and by change the top/left values, you can move it in the direction you want, sample 2 has 33% as top value.
Update based on question edit
The small X/Y-axis offset is caused by the rotate being executed before the translate, so change your #keyframes rule to this, showed in sample 3 and an update of your fiddle
#keyframes rotatePreloader {
0% {
transform: translate(-50%, -50%) rotate(0deg);
}
100% {
transform: translate(-50%, -50%) rotate(360deg);
}
}
Sample 1
.preloader {
position: fixed;
display: inline-block;
z-index: 99;
top: 50%;
left: 50%;
width: 60px;
height: 60px;
transform: translate(-50%,-50%);
/*=====rest is just animation and aesthetics======*/
border: 3px solid #8A2EE6;
border-radius: 50%;
border-bottom: 3px solid black;
box-shadow: 0px 0px 20px 1px rgba(153, 102, 255, 0.5) inset, 0px 0px 20px 1px rgba(153, 102, 255, 0.5);
animation-name: rotatePreloader;
animation-duration: 0.65s;
animation-direction: normal;
animation-iteration-count: infinite;
animation-timing-function: linear;
transition: opacity 1s;
}
<div class="preloader"></div>
Sample 2
.preloader {
position: fixed;
display: inline-block;
z-index: 99;
top: 33%;
left: 50%;
width: 60px;
height: 60px;
transform: translate(-50%,-50%);
/*=====rest is just animation and aesthetics======*/
border: 3px solid #8A2EE6;
border-radius: 50%;
border-bottom: 3px solid black;
box-shadow: 0px 0px 20px 1px rgba(153, 102, 255, 0.5) inset, 0px 0px 20px 1px rgba(153, 102, 255, 0.5);
animation-name: rotatePreloader;
animation-duration: 0.65s;
animation-direction: normal;
animation-iteration-count: infinite;
animation-timing-function: linear;
transition: opacity 1s;
}
<div class="preloader"></div>
Sample 3
.leftPreloaderBG {
position: fixed;
background-color: black;
width: 50%;
height: 100%;
z-index: 98;
top: 0px;
left: 0px;
transition: width 1s;
}
.leftPreloaderBG.loaded {
width: 0;
}
.rightPreloaderBG {
position: fixed;
background-color: black;
width: 50%;
height: 100%;
z-index: 98;
top: 0px;
right: 0px;
transition: width 1s;
}
.rightPreloaderBG.loaded {
width: 0;
}
#keyframes rotatePreloader {
0% {
transform: translate(-50%, -50%) rotate(0deg);
}
100% {
transform: translate(-50%, -50%) rotate(360deg);
}
}
.preloader {
position: fixed;
display: inline-block;
z-index: 99;
top: 33%;
left: 50%;
width: 60px;
height: 60px;
transform: translate(-50%, -50%);
/*=====rest is just animation and aesthetics======*/
border: 3px solid #8A2EE6;
border-radius: 50%;
border-bottom: 3px solid black;
box-shadow: 0px 0px 20px 1px rgba(153, 102, 255, 0.5) inset, 0px 0px 20px 1px rgba(153, 102, 255, 0.5);
animation-name: rotatePreloader;
animation-duration: 0.65s;
animation-direction: normal;
animation-iteration-count: infinite;
animation-timing-function: linear;
transition: opacity 1s;
}
.preloader.loaded {
opacity: 0;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
margin: 0;
padding: 0;
width: 100%;
color: white;
font-size: 1em;
background-color: gray;
background-position: center;
background-repeat: repeat;
}
<body>
<div class="preloader"></div>
<div class="leftPreloaderBG"></div>
<div class="rightPreloaderBG"></div>
</body>
It is because you override the transform translate value in the keyframe animation. Try it like this:
.leftPreloaderBG {
position: fixed;
background-color: black;
width: 50%;
height: 100%;
z-index: 98;
top: 0px;
left: 0px;
transition: width 1s;
}
.leftPreloaderBG.loaded {
width: 0;
}
.rightPreloaderBG {
position: fixed;
background-color: black;
width: 50%;
height: 100%;
z-index: 98;
top: 0px;
right: 0px;
transition: width 1s;
}
.rightPreloaderBG.loaded {
width: 0;
}
#keyframes rotatePreloader {
0% {
transform: translate(-50%, -50%) rotate(0deg);
}
100% {
transform: translate(-50%, -50%) rotate(360deg);
}
}
.preloader {
position: fixed;
display: inline-block;
z-index: 99;
top: 33%;
left: 50%;
width: 60px;
height: 60px;
transform: translate(-50%, -50%);
/*=====rest is just animation and aesthetics======*/
border: 3px solid #8A2EE6;
border-radius: 50%;
border-bottom: 3px solid black;
box-shadow: 0px 0px 20px 1px rgba(153, 102, 255, 0.5) inset, 0px 0px 20px 1px rgba(153, 102, 255, 0.5);
animation-name: rotatePreloader;
animation-duration: 0.65s;
animation-direction: normal;
animation-iteration-count: infinite;
animation-timing-function: linear;
transition: opacity 1s;
}
.preloader.loaded {
opacity: 0;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
margin: 0;
padding: 0;
width: 100%;
color: white;
font-size: 1em;
background-color: gray;
background-position: center;
background-repeat: repeat;
}
<body>
<div class="preloader"></div>
<div class="leftPreloaderBG"></div>
<div class="rightPreloaderBG"></div>
</body>
I have created a ripple effect in this circle. Everything looks great, but I want that this effect happen more often. It takes to long time for the other wave to appear when the other is gone. I tried to increase the animation speed, but it doesn't look good:
Here is what I've done so far:
.pulse {
width: 300px;
height: 300px;
background: #bdebca;
border: 1px solid #b9e8c9;
border-radius: 50%;
z-index: -1;
text-align: center;
position: absolute;
transform: scale(0.1, 0.1);
animation: ring-1 2s ease-out infinite
}
#keyframes ring-1 {
0% {
transform: scale(0.1, 0.1);
opacity: 0
}
50% {
opacity: 1
}
100% {
transform: scale(1.2, 1.2);
opacity: 0
}
}
.ripple-icon .inner {
background-color: lightblue;
color: #fff;
/* animation: pulse 2s infinite; */
}
.icon .inner {
width: 200px;
height: 200px;
text-align: center;
line-height: 200px;
display: inline-block;
border-radius: 100%;
font-size: 22px;
color: #fff;
text-align: center;
font-weight: 700;
position: relative;
top: 50%;
transform: translateY(-50%);
box-shadow: 0px 0px 103.74px 10.26px rgba(250, 250, 250, 0.5);
cursor: pointer;
}
.icon {
width: 300px;
height: 300px;
border-radius: 100%;
text-align: center;
position: absolute;
top: 50%;
text-align: center;
transform: translateY(-50%);
margin: 0 auto;
left: 50%;
margin-left: -150px;
}
<div class="ripple-icon icon hvr-bounce-in">
<div class="inner">
Ripple
</div>
<div class="pulse" style="left: 0px; top: 0px;"></div>
</div>
Something like this? Add more ripple's and delay the start of animation by 0.5s, 1s, 1.5s and 2s respectively.
Read more about animation delay:
https://developer.mozilla.org/en/docs/Web/CSS/animation-delay
https://css-tricks.com/almanac/properties/a/animation/
.pulse1,
.pulse2,
.pulse3,
.pulse4 {
width: 300px;
height: 300px;
background: #bdebca;
border: 1px solid #b9e8c9;
border-radius: 50%;
z-index: -1;
text-align: center;
position: absolute;
transform: scale(0.1, 0.1);
}
.pulse1 {
animation: ring-1 2s 0.5s ease-out infinite;
}
.pulse2 {
animation: ring-1 2s 1s ease-out infinite;
}
.pulse3 {
animation: ring-1 2s 1.5s ease-out infinite;
}
.pulse4 {
animation: ring-1 2s 2s ease-out infinite;
}
#keyframes ring-1 {
0% {
transform: scale(0.1, 0.1);
opacity: 0
}
50% {
opacity: 1
}
100% {
transform: scale(1.2, 1.2);
opacity: 0
}
}
.ripple-icon .inner {
background-color: lightblue;
color: #fff;
/* animation: pulse 2s infinite; */
}
.icon .inner {
width: 200px;
height: 200px;
text-align: center;
line-height: 200px;
display: inline-block;
border-radius: 100%;
font-size: 22px;
color: #fff;
text-align: center;
font-weight: 700;
position: relative;
top: 50%;
transform: translateY(-50%);
box-shadow: 0px 0px 103.74px 10.26px rgba(250, 250, 250, 0.5);
cursor: pointer;
}
.icon {
width: 300px;
height: 300px;
border-radius: 100%;
text-align: center;
position: absolute;
top: 50%;
text-align: center;
transform: translateY(-50%);
margin: 0 auto;
left: 50%;
margin-left: -150px;
}
<div class="ripple-icon icon hvr-bounce-in">
<div class="inner">
Ripple
</div>
<div class="pulse1" style="left: 0px; top: 0px;"></div>
<div class="pulse2" style="left: 0px; top: 0px;"></div>
<div class="pulse3" style="left: 0px; top: 0px;"></div>
<div class="pulse4" style="left: 0px; top: 0px;"></div>
</div>
In the .pulse css you can change the animation: ring-1 0.5s ease-out infinite
I have changed the speed from 2s to 0.5s
.button {
text-align: left;
background-color: #012839;
text-decoration: none;
text-transform: uppercase;
font-family: 'Exo 2', sans-serif;
font-weight: 200;
font-size: 30px;
display: inline-block;
position: relative;
margin-top: 50px;
margin-left: 20px;
text-align: center;
width: 50px;
color: #00c7ec;
border: 1px solid #00c7ec;
border-radius: 5px;
line-height: 3em;
padding-left: 5em;
padding-right: 5em;
box-shadow: 0 0 0 0 transparent;
-webkit-transition: all 0.2s ease-in;
-moz-transition: all 0.2s ease-in;
transition: all 0.2s ease-in;
}
.button:hover {
color: white;
box-shadow: 0 0 30px 0 rgba(0, 199, 236, 0.5);
background-color: #00c7ec;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.button:hover:before {
-webkit-animation: shine 0.5s 0s linear;
-moz-animation: shine 0.5s 0s linear;
animation: shine 0.5s 0s linear;
}
.button:active {
box-shadow: 0 0 0 0 transparent;
-webkit-transition: box-shadow 0.2s ease-in;
-moz-transition: box-shadow 0.2s ease-in;
transition: box-shadow 0.2s ease-in;
}
.button:before {
content: '';
display: block;
width: 0px;
height: 86%;
position: absolute;
top: 7%;
left: 0%;
opacity: 0;
background: white;
box-shadow: 0 0 15px 3px white;
-webkit-transform: skewX(-20deg);
-moz-transform: skewX(-20deg);
-ms-transform: skewX(-20deg);
-o-transform: skewX(-20deg);
transform: skewX(-20deg);
}
#-webkit-keyframes shine {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
#-moz-keyframes shine {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
#keyframes shine {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
Gallery
I wanted to use this button in my personal project but the problem I am having is that the text in the button i.e. "Gallery" is not getting center aligned even after I put the "text-align:"center" in the button class.
Because of you define width 50px; now do this
add width: auto; or remove width: 50px;
as like this
.button {
text-align: left;
background-color: #012839;
text-decoration: none;
text-transform: uppercase;
font-family: 'Exo 2', sans-serif;
font-weight: 200;
font-size: 30px;
display: inline-block;
position: relative;
margin-top: 50px;
margin-left: 20px;
text-align: center;
color: #00c7ec;
border: 1px solid #00c7ec;
border-radius: 5px;
line-height: 3em;
padding-left: 5em;
padding-right: 5em;
box-shadow: 0 0 0 0 transparent;
-webkit-transition: all 0.2s ease-in;
-moz-transition: all 0.2s ease-in;
transition: all 0.2s ease-in;
}
.button:hover {
color: white;
box-shadow: 0 0 30px 0 rgba(0, 199, 236, 0.5);
background-color: #00c7ec;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.button:hover:before {
-webkit-animation: shine 0.5s 0s linear;
-moz-animation: shine 0.5s 0s linear;
animation: shine 0.5s 0s linear;
}
.button:active {
box-shadow: 0 0 0 0 transparent;
-webkit-transition: box-shadow 0.2s ease-in;
-moz-transition: box-shadow 0.2s ease-in;
transition: box-shadow 0.2s ease-in;
}
.button:before {
content: '';
display: block;
width: 0px;
height: 86%;
position: absolute;
top: 7%;
left: 0%;
opacity: 0;
background: white;
box-shadow: 0 0 15px 3px white;
-webkit-transform: skewX(-20deg);
-moz-transform: skewX(-20deg);
-ms-transform: skewX(-20deg);
-o-transform: skewX(-20deg);
transform: skewX(-20deg);
}
#-webkit-keyframes shine {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
#-moz-keyframes shine {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
#keyframes shine {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
Gallery
Add .button { width: auto; } to get your result
change
padding-left : 5em to 2.5em
I had removed padding and added min-width:220px:
.button {
text-align: left;
background-color: #012839;
text-decoration: none;
text-transform: uppercase;
font-family: 'Exo 2', sans-serif;
font-weight: 200;
font-size: 30px;
display: inline-block;
position: relative;
margin-top: 50px;
margin-left: 20px;
text-align: center;
color: #00c7ec;
min-width: 220px; /*Here you can give any value other then 220px*/
border: 1px solid #00c7ec;
border-radius: 5px;
line-height: 3em;
box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
-webkit-transition: all 0.2s ease-in;
-moz-transition: all 0.2s ease-in;
transition: all 0.2s ease-in;
}
.button:hover {
color: white;
box-shadow: 0 0 30px 0 rgba(0, 199, 236, 0.5);
background-color: #00c7ec;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.button:hover:before {
-webkit-animation: shine 0.5s 0s linear;
-moz-animation: shine 0.5s 0s linear;
animation: shine 0.5s 0s linear;
}
.button:active {
box-shadow: 0 0 0 0 transparent;
-webkit-transition: box-shadow 0.2s ease-in;
-moz-transition: box-shadow 0.2s ease-in;
transition: box-shadow 0.2s ease-in;
}
.button:before {
content: '';
display: block;
width: 0px;
height: 86%;
position: absolute;
top: 7%;
left: 0%;
opacity: 0;
background: white;
box-shadow: 0 0 15px 3px white;
-webkit-transform: skewX(-20deg);
-moz-transform: skewX(-20deg);
-ms-transform: skewX(-20deg);
-o-transform: skewX(-20deg);
transform: skewX(-20deg);
}
#-webkit-keyframes shine {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
#-moz-keyframes shine {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
#keyframes shine {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
Gallery