CSS3 Keyframe Animation on page load only? - html

What I have here is a profile button that animates in, and performs a different animation on hover. However the entrance animation repeats when my mouse leaves the element. Is there a way to make sure that an animation is only triggered once per page load?
.profile {
width: 125px;
height: 125px;
background-image: url(graphics/profile1.jpg);
border-style: solid;
border-color: white;
border-radius: 50%;
margin-left: 80px;
outline: 1px solid transparent;
float: left;
animation: popIn 1s;
}
.profile:hover{
width: 125px;
height: 125px;
border-style: solid;
border-color: red;
box-shadow: 0 0 0 0 rgba(155, 0, 2, 0.6);
border-radius: 50%;
-webkit-animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1);
-moz-animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1);
-ms-animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1);
animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1);
}
#keyframes popIn{
0% {
transform: scale(0.1);
opacity: 0;
}
60% {
transform: scale(1.2);
opacity: 1;
}
100% {
transform: scale(1);
}
}
#-webkit-keyframes pulse {to {box-shadow: 0 0 0 45px rgba(232, 76, 61, 0);}}
#-moz-keyframes pulse {to {box-shadow: 0 0 0 45px rgba(232, 76, 61, 0);}}
#-ms-keyframes pulse {to {box-shadow: 0 0 0 45px rgba(232, 76, 61, 0);}}
#keyframes pulse {to {box-shadow: 0 0 0 45px rgba(232, 76, 61, 0);}}

Here is a link to a similar question that might help you out.
Run CSS3 animation only once (at page loading)
Personally I would add an extra class to the div that handles all the entrance animations and then use javascript to remove that class once the cursor moves inside the div. I'll make a js fiddle and show you an example, just give me a few minutes.
Edit for fiddle link: https://jsfiddle.net/0uaktv10/
html:
<div class="profile load-in" style="background: blue; width: 100px; height: 100px;"></div>
Css:
enter .profile {
width: 125px;
height: 125px;
background-image: url(graphics/profile1.jpg);
border-style: solid;
border-color: white;
border-radius: 50%;
margin-left: 80px;
outline: 1px solid transparent;
float: left;
}
.load-in {
animation: popIn 1s;
}
.profile:hover{
width: 125px;
height: 125px;
border-style: solid;
border-color: red;
box-shadow: 0 0 0 0 rgba(155, 0, 2, 0.6);
border-radius: 50%;
-webkit-animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1);
-moz-animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1);
-ms-animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1);
animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1);
}
#keyframes popIn{
0% {
transform: scale(0.1);
opacity: 0;
}
60% {
transform: scale(1.2);
opacity: 1;
}
100% {
transform: scale(1);
}
}
#-webkit-keyframes pulse {to {box-shadow: 0 0 0 45px rgba(232, 76, 61, 0);}}
#-moz-keyframes pulse {to {box-shadow: 0 0 0 45px rgba(232, 76, 61, 0);}}
#-ms-keyframes pulse {to {box-shadow: 0 0 0 45px rgba(232, 76, 61, 0);}}
#keyframes pulse {to {box-shadow: 0 0 0 45px rgba(232, 76, 61, 0);}}
jQuery:
$(".profile").hover(function(){
$(".profile").removeClass("load-in")
})

Related

how to stop rapid shaking on hover

iframe {
box-shadow: 0 10px 18px 0 rgba(0, 0, 0, 0.144),
0 12px 30px 0 rgba(0, 0, 0, 0.377);
}
iframe:hover {
filter: brightness(95%);
transition: 0.5s ease-in-out;
animation: iframes 0.8s linear both 1;
box-shadow: 0 12px 24px 0 rgba(0, 0, 0, 0.212),
0 16px 35px 0 rgba(0, 0, 0, 0.493);
}
#keyframes iframes {
0% {
transform: rotate(0deg);
}
25% {
transform: rotate(7deg);
}
50% {
transform: rotate(0deg);
}
75% {
transform: rotate(-7deg);
}
100% {
transform: rotate(0deg) ;
}
}
<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d14023.546898520377!2d77.2038604!3d28.5130556!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0xd87ca9af3beebff5!2sShrishti%20Flower!5e0!3m2!1sen!2sin!4v1613667773659!5m2!1sen!2sin" width="60%" height="400" frameborder="0" style="border:2.7px blue solid; margin-bottom: 2rem; border-radius: 1rem; " allowfullscreen="" aria-hidden="false" tabindex="0"></iframe>
<!-- iframe --!>
when I hover on this iframe it starts to shaking rapidly and the animation trigger more than once. I don't know why this happens . pls help me to solve it.
The shaking rapidly part I do not experience with your code snippet, the repeated animation is caused by having the animation on hover, this will reset the count everytime a user hovers the iframe.
By setting the animation on the iframe itself you can prevent this. You set start the animation on hover with animation-play-state.
iframe {
box-shadow: 0 10px 18px 0 rgba(0, 0, 0, 0.144),
0 12px 30px 0 rgba(0, 0, 0, 0.377);
animation: iframes 0.8s linear both 1;
animation-play-state: paused;
}
iframe:hover {
filter: brightness(95%);
transition: 0.5s ease-in-out;
animation-play-state: running;
box-shadow: 0 12px 24px 0 rgba(0, 0, 0, 0.212),
0 16px 35px 0 rgba(0, 0, 0, 0.493);
}
#keyframes iframes {
0% {
transform: rotate(0deg);
}
25% {
transform: rotate(7deg);
}
50% {
transform: rotate(0deg);
}
75% {
transform: rotate(-7deg);
}
100% {
transform: rotate(0deg) ;
}
}
<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d14023.546898520377!2d77.2038604!3d28.5130556!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0xd87ca9af3beebff5!2sShrishti%20Flower!5e0!3m2!1sen!2sin!4v1613667773659!5m2!1sen!2sin" width="60%" height="400" frameborder="0" style="border:2.7px blue solid; margin-bottom: 2rem; border-radius: 1rem; " allowfullscreen="" aria-hidden="false" tabindex="0"></iframe>
Please add "animation-iteration-count" to "infinite" for the shaking rapidly.
iframe {
box-shadow: 0 10px 18px 0 rgba(0, 0, 0, 0.144),
0 12px 30px 0 rgba(0, 0, 0, 0.377);
}
iframe:hover {
filter: brightness(95%);
transition: 0.5s ease-in-out;
animation: iframes 0.8s linear both 1;
box-shadow: 0 12px 24px 0 rgba(0, 0, 0, 0.212),
0 16px 35px 0 rgba(0, 0, 0, 0.493);
animation-iteration-count:infinite;
}
#keyframes iframes {
0% {
transform: rotate(0deg);
}
25% {
transform: rotate(7deg);
}
50% {
transform: rotate(0deg);
}
75% {
transform: rotate(-7deg);
}
100% {
transform: rotate(0deg) ;
}
}
<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d14023.546898520377!2d77.2038604!3d28.5130556!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0xd87ca9af3beebff5!2sShrishti%20Flower!5e0!3m2!1sen!2sin!4v1613667773659!5m2!1sen!2sin" width="60%" height="400" frameborder="0" style="border:2.7px blue solid; margin-bottom: 2rem; border-radius: 1rem; " allowfullscreen="" aria-hidden="false" tabindex="0"></iframe>

Pause CSS animation and change the animated property on hover - but don't restart another animation on mouse leave

I have a button that has 2 animations: a one-time fadeInBottom (on page load) and an infinite pulsing box-shadow. On hover, I want to pause the pulse and make the box-shadow stronger.
On first glance, I thought this would be easy. On the :hover pseudo-class, set animation-play-state: paused and then set a new box-shadow. That doesn't work, I guess because CSS doesn't let you directly change properties that are also being adjusted in animations.
.button {
animation: fadeInBottom 1s, fadeInOutShadow ease-in-out 1.2s alternate infinite;
&:hover {
animation-play-state: paused;
box-shadow: 0 0 35px rgba(255, 215, 0, 0.9);
}
}
#keyframes fadeInBottom {
0% {
opacity: 0;
-webkit-transform: translateY(10px);
transform: translateY(10px);
}
100% {
opacity: 1;
-webkit-transform: translateY(0);
transform: translateY(0);
}
}
#keyframes fadeInOutShadow {
0% {
-webkit-box-shadow: 0 0 25px rgba(255, 215, 0, 0.5);
box-shadow: 0 0 25px rgba(255, 215, 0, 0.5);
}
100% {
-webkit-box-shadow: 0 0 25px rgba(255, 215, 0, 0.8);
box-shadow: 0 0 25px rgba(255, 215, 0, 0.8);
}
}
Ok, try #2. I checked a few questions on here and found one idea - use :hover {animation:0} to kill the animation, then set box-shadow.
Stop animation and start transition on hover
It's almost OK, but this doesn't work because of my fadeInBottom animation: every time I mouse leave the button, the fadeInBottom animation runs again.
.button {
animation: fadeInBottom 1s, fadeInOutShadow ease-in-out 1.2s alternate infinite;
&:hover {
animation: 0;
box-shadow: 0 0 35px rgba(255, 215, 0, 0.9);
}
}
I have three potential options (I think) to continue:
Remove the fadeInBottom animation on mouse leave (likely with jQuery.)
Only run the fadeInBottom animation once, on page load, and ignore :hover and mouse leave events. Is there a CSS way? jQuery? (Don't know if this is possible.)
Is there actually a simple property attribute I don't know about that can accomplish 1 or 2?
Any recommendations on which of these would be best? First-time question asker here. Thanks!
ok as long as you didn't replied yet, here is your solution, i hope it meets your code aims, regards,
$(document).ready(function(){
$(".button").css("animation", "fadeInBottom 1s");
setTimeout(function(){
$(".button").css("animation", "fadeInOutShadow ease-in-out 1.2s alternate infinite");
}, 1200);
});
$(".button").hover(function(){
$(".button").css({"animation": "0", "box-shadow": "0 0 35px rgba(250, 215, 0, 0.9)"});
}, function(){
$(".button").css({"box-shadow": "", "animation": "fadeInOutShadow ease-in-out 1.2s alternate infinite"});
});
.button {
&:hover {
box-shadow: 0 0 35px rgba(255, 215, 0, 0.9);
}
}
#keyframes fadeInBottom {
0% {
opacity: 0;
-webkit-transform: translateY(10px);
transform: translateY(10px);
}
100% {
opacity: 1;
-webkit-transform: translateY(0);
transform: translateY(0);
}
}
#keyframes fadeInOutShadow {
0% {
-webkit-box-shadow: 0 0 25px rgba(255, 215, 0, 0.5);
box-shadow: 0 0 25px rgba(255, 215, 0, 0.5);
}
100% {
-webkit-box-shadow: 0 0 25px rgba(255, 215, 0, 0.8);
box-shadow: 0 0 25px rgba(255, 215, 0, 0.8);
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button class="button">Button</button>

Linking Pulse buttons and make tables disappear

Hey guys I am having trouble linking my pulse buttons to their corresponding table, my code is attached can anyone give some feed back on how to make only one table show at a time based on a click on the pulse button?
https://codepen.io/jmrowe0231/pen/KGVYLp
label div.pulse-button {
position:relative;
width: 25px;
height: 25px;
border: none;
box-shadow: 0 0 0 0 rgba(232, 76, 61, 0.7);
border-radius: 50%;
background-color: #00aed6;
background-image: url(http://image.carnivalcruiselineemail.com/lib/fe9513727761047c7c/m/10/plus_icon.png);
background-size: cover;
background-repeat: no-repeat;
cursor: pointer;
-webkit-animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1);
-moz-animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1);
-ms-animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1);
animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1);
}
label[for=Mexico1] div.pulse-button {
left: -143px;
top: -175px;
}
label[for=Mexico2] div.pulse-button {
left: 280px;
top: -192px;
}
label[for=Mexico3] div.pulse-button {
left: -243px;
top: -278px;
}
# -webkit-keyframes pulse {
to {
box-shadow: 0 0 0 45px rgba(232, 76, 61, 0);
}
}
#-moz-keyframes pulse {
to {
box-shadow: 0 0 0 45px rgba(232, 76, 61, 0);
}
}
#-ms-keyframes pulse {
to {
box-shadow: 0 0 0 45px rgba(232, 76, 61, 0);
}
}
#keyframes pulse {
to {
box-shadow: 0 0 0 45px rgba(232, 76, 61, 0);
}

Unable to animate transform: scale and box-shadow simultaneously

I need to animate the circle's box-shadow and scale it down to 1 from 1.6x during the same transition period of box-shadow.
The issue I'm facing is the animation of scale is happening after the animation of box-shadow is done.
body {
background-color: #333;
}
.ripple {
width: 20px;
margin: 50px auto;
height: 20px;
background: #ccc;
border-radius: 50%;
animation: rippleeff 2s ease infinite;
}
#keyframes rippleeff {
0% {
-moz-box-shadow: 0 0 0 0 rgba(204, 169, 44, 0.4);
box-shadow: 0 0 0 0 rgba(204, 169, 44, 0.4);
transform: scale(1.4);
}
70% {
-moz-box-shadow: 0 0 0 20px rgba(204, 169, 44, 0);
box-shadow: 0 0 0 20px rgba(204, 169, 44, 0);
transform: scale(1.6);
}
100% {
-moz-box-shadow: 0 0 0 0 rgba(204, 169, 44, 0);
box-shadow: 0 0 0 0 rgba(204, 169, 44, 0);
transform: scale(1);
}
}
<div class="ripple">
</div>
Fiddle
When your transform: scale(1.6), your box-shadow become transparent and after that when you going to scale(1) your box-shadow is animating but you can't see it because it's transparent...so change box-shadow color
Also changed scale value in the code...
body {
background-color: #333;
}
.ripple {
width: 20px;
margin: 50px auto;
height: 20px;
background: #ccc;
border-radius: 50%;
animation: rippleeff 2s linear infinite;
}
#keyframes rippleeff {
0% {
box-shadow: 0 0 0 0 rgba(204, 169, 44, 0.4);
transform: scale(1);
}
50% {
box-shadow: 0 0 0 20px rgba(204, 169, 44, 0);
transform: scale(1.6);
}
100% {
box-shadow: 0 0 0 0 rgba(204, 169, 44, 0.4);
transform: scale(1);
}
}
<div class="ripple">
</div>

Animation of text-shadow in CSS

I have the following code where I do an animation in CSS moving a div. But I wanted to also animate the shadow of the text simulating somehow a weight for my text:
div#main {
background-color: #2E2E2E;
}
div#lblCaption {
margin-bottom: 0px;
color: #C7C7C7;}
div#NodeCaptionContainer{
animation-duration: .7s;
animation-name: fadeAndScale;
animation-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
}
#keyframes fadeAndScale {
from {
opacity: 0;
transform: scale(.9, .9);
text-shadow: 0 0 .75px rgb(255, 255, 255), 0 0 .75px rgb(255, 255, 255);
}
to {
opacity: 1;
transform: scale(1, 1);
text-shadow: 0 0 .0px rgb(255, 255, 255), 0 0 .0px rgb(255, 255, 255);
}
}
<div id="main">
<div id="NodeCaptionContainer">
<div id="lblCaption" class="pretty p-default p-thick p-pulse"><p class="noMargin"> Node: 1:9 Type: Function Read: 480B Write: 1088B </p></div>
</div>
</div>
The problem is that the animation for the translation is done smoothly by the animation-timing-function, but not for the shadow. I wanted to also smooth the shadow transition. Is there a way to smooth also the shadow transition in the CSS?
https://jsfiddle.net/Liamm12/6d9p5uun/67/
Defined text-shadow in NodeCaptionContainer and use forwards to not get back to the same code of NodeCaptionContainer then hide it using keyframes
div#main {
background-color: #2E2E2E;
}
div#lblCaption {
margin-bottom: 0px;
color: #C7C7C7;}
div#NodeCaptionContainer{
-webkit-animation: fadeAndScale .7s ease-in-out forwards;
animation: fadeAndScale .7s ease-in-out forwards;
text-shadow: 0 0 .75px red, 0 0 .75px red;
}
#keyframes fadeAndScale {
from {
opacity: 0;
transform: scale(.9, .9);
}
to {
opacity: 1;
transform: scale(1, 1);
text-shadow: 0 0 0 rgb(255, 255, 255);
}
}
<div id="main">
<div id="NodeCaptionContainer">
<div id="lblCaption" class="pretty p-default p-thick p-pulse"><p class="noMargin"> Node: 1:9 Type: Function Read: 480B Write: 1088B </p></div>
</div>
</div>