Animation of text-shadow in CSS - html

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>

Related

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>

Need cross instead tick in SVG

I need to convert the tick mark to a cross mark, I have no knowledge of SVG, so anyone can convert the following tick animation to a cross animation?
body {
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.checkmark {
width: 56px;
height: 56px;
border-radius: 50%;
display: block;
stroke-width: 2;
stroke: #fff;
stroke-miterlimit: 10;
box-shadow: inset 0px 0px 0px #7ac142;
animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s both;
}
.checkmark__circle {
stroke-dasharray: 166;
stroke-dashoffset: 166;
stroke-width: 2;
stroke-miterlimit: 10;
stroke: #7ac142;
fill: none;
animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.checkmark__check {
transform-origin: 50% 50%;
stroke-dasharray: 48;
stroke-dashoffset: 48;
animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}
#keyframes stroke {
100% {
stroke-dashoffset: 0;
}
}
#keyframes scale {
0%, 100% {
transform: none;
}
50% {
transform: scale3d(1.1, 1.1, 1);
}
}
#keyframes fill {
100% {
box-shadow: inset 0px 0px 0px 30px #7ac142;
}
}
<svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52"><circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/><path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/></svg>
I have tried my best but the tick join point doesn't splits, tick tail and head attached, any help will be appreciated.
My thought process:
Not really a StackOverflow-worthy question...
But I am a sucker for SVG
I'm gonna do it anyway.
So here you go! I've just changed the <path /> for you.
d="M14.1 14.1l23.8 23.8 m0,-23.8 l-23.8,23.8"
Start in the top-left (at 14.1,14.1), go diagonally down-right for 23.8 units, then "pick up the pen" and move 23.8 units up before going down-left for 23.8 units.
Looks good to me!
body {
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.checkmark {
width: 56px;
height: 56px;
border-radius: 50%;
display: block;
stroke-width: 2;
stroke: #fff;
stroke-miterlimit: 10;
box-shadow: inset 0px 0px 0px #7ac142;
animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s both;
}
.checkmark__circle {
stroke-dasharray: 166;
stroke-dashoffset: 166;
stroke-width: 2;
stroke-miterlimit: 10;
stroke: #7ac142;
fill: none;
animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.checkmark__check {
transform-origin: 50% 50%;
stroke-dasharray: 48;
stroke-dashoffset: 48;
animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}
#keyframes stroke {
100% {
stroke-dashoffset: 0;
}
}
#keyframes scale {
0%, 100% {
transform: none;
}
50% {
transform: scale3d(1.1, 1.1, 1);
}
}
#keyframes fill {
100% {
box-shadow: inset 0px 0px 0px 30px #7ac142;
}
}
<svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52"><circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/><path class="checkmark__check" fill="none" d="M14.1 14.1l23.8 23.8 m0,-23.8 l-23.8,23.8"/></svg>

CSS3 Keyframe Animation on page load only?

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")
})

How to change the button colour after playing animation in css

I am trying to change colour of button after playing animation for some time. What I have searched and found that, it needs to change a new frame. Here is my CSS:
.header-button {
font-size: 12px;
text-shadow: 0 -1px 0 rgba(0, 0, 0, .8);
color: #fbd3cc;
text-decoration: none;
font-weight: normal;
height: 30px;
border: 1px solid rgba(255, 255, 255, .4);
border-radius: 3px;
-webkit-border-radius: 3px;
display: inline;
background: #026890;
}
#keyframes fadeIn {
from {
opacity: 0;
}
}
.animate-flicker {
animation: fadeIn 0.5s infinite alternate;
animation-iteration-count: 10;
-moz-animation-name: changecolor;
}
#keyframes changecolor {
{
color: red;
}
}
<button class="header-button animate-flicker">Menue
</button>
Can some one tell me how i can change the button colour after playing animation for 5 times in css
You need to make both animations either:
In the same keyframes
#keyframes fadeInNColor {
from {
opacity: 0;
}
to {
color: red;
}
}
or call each of them from the same rule
animation: fadeIn 0.5s infinite alternate, changecolor 0.5s infinite alternate forwards;
.header-button {
font-size: 12px;
text-shadow: 0 -1px 0 rgba(0, 0, 0, .8);
color: #fbd3cc;
text-decoration: none;
font-weight: normal;
height: 30px;
border: 1px solid rgba(255, 255, 255, .4);
border-radius: 3px;
-webkit-border-radius: 3px;
display: inline-block;
background: #026890;
}
#keyframes fadeIn {
from {
opacity: 0;
}
}
.animate-flicker {
animation:
fadeIn 0.5s infinite alternate, /* first animation*/
changecolor 0.5s infinite alternate forwards;/* second animation freezed */
animation-iteration-count: 5;
}
#keyframes changecolor {
to {
color: red;
}
}
<button class="header-button animate-flicker">Menue
</button>
you can add a span into the button tag and apply the color change to the span by delaying it by a few seconds to finish the nimation
Hope this is what you are looking for:
#keyframes changecolor
{
to {background:red;}
}

Animate placeholder text: Go to side and loose opacity

I'm creating a search box, with the placeholder text getting animated on focus. I've implemented that using css. When it gets focused, the placeholder text gets moved over all the way to the right while loosing opacity. When it looses focus, it gets moved its original place and the opacity is applied again.
The problem is when you unfocus, (firs focus, then unfocus,) the searchbox gets a larger width. So if the parent div is set to overflow: auto, the x-axis scroll bar shows up. I can obviously do overflow-x: hidden, but that's sort of a hack.
How can I get the same animation without having an overflow?
JSFiddle
#wrapper {
width: 350px;
background-color: brown;
overflow: auto;
}
#search {
margin: 0 .5rem;
padding: .5rem;
width: 95%;
background-color: green;
color: white;
border: none;
border-bottom: 1px solid rgba(255, 255, 255, 0.5);
font-size: 1.15rem;
transition: translateX 6s ease-in;
margin-bottom: 15px;
}
#search:focus {
outline: none;
border: 1px solid rgba(255, 255, 255, 0.5);
}
#search:focus::-webkit-input-placeholder {
-webkit-transform: translateX(70%);
transform: translateX(70%);
opacity: 0;
}
#search:focus::-webkit-input-placeholder:-moz-placeholder {
-webkit-transform: translateX(70%);
transform: translateX(70%);
opacity: 0;
}
#search:focus::-webkit-input-placeholder::-moz-placeholder {
-webkit-transform: translateX(70%);
transform: translateX(70%);
opacity: 0;
}
#search:focus::-webkit-input-placeholder:-ms-input-placeholder {
-webkit-transform: translateX(70%);
transform: translateX(70%);
opacity: 0;
}
#search:focus::-webkit-input-placeholder::-ms-input-placeholder {
-webkit-transform: translateX(70%);
transform: translateX(70%);
opacity: 0;
}
#search::-webkit-input-placeholder {
color: rgba(255, 255, 255, 0.8);
-webkit-transition: ease-in 0.3s;
transition: ease-in 0.3s;
-webkit-transform-origin: 0 50%;
transform-origin: 0 50%;
}
#search:-moz-placeholder {
color: rgba(255, 255, 255, 0.8);
-webkit-transition: ease-in 0.3s;
transition: ease-in 0.3s;
transform-origin: 0 50%;
}
#search::-moz-placeholder {
color: rgba(255, 255, 255, 0.8);
-webkit-transition: ease-in 0.3s;
transition: ease-in 0.3s;
transform-origin: 0 50%;
}
#search:-ms-input-placeholder {
color: rgba(255, 255, 255, 0.8);
-webkit-transition: ease-in 0.3s;
transition: ease-in 0.3s;
transform-origin: 0 50%;
}
#search::-ms-input-placeholder {
color: rgba(255, 255, 255, 0.8);
-webkit-transition: ease-in 0.3s;
transition: ease-in 0.3s;
transform-origin: 0 50%;
}
<div id="wrapper">
<input type="search" placeholder="Search Me" id="search">
</div>
UPDATED
Plnker
:focus::-webkit-input-placeholder {
opacity: 0;
transform: translate(70%);
-webkit-transition: all 0.35s ease-in-out;
transition: all 0.35s ease-in-out;
}