css3 animation, change property after animation starts? - html

please see below:
#-webkit-keyframes myfirst /* Safari and Chrome */
{
0% { height:200px; }
50% {opacity:1}
50% {height:300px; opacity: 0; }
}
I would like to start fading the object away only 50% thorugh the animation. not at the beginning. This currently doesn't do any opacity animation.

Not getting your question quiet well but I assume you want to delay the start of your animation, if it's that so.. than you can use animation-delay property... This will help you in delay your animation by few seconds
Demo (Modified demo of my answer here)
.blink_me {
animation-name: blinker;
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: infinite;
-webkit-animation-name: blinker;
-webkit-animation-duration: 1s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
-moz-animation-delay: 5s;
-webkit-animation-delay: 5s;
animation-delay: 5s;
}
#-moz-keyframes blinker {
0% { opacity: 1.0; }
50% { opacity: 0.0; }
100% { opacity: 1.0; }
}
#-webkit-keyframes blinker {
0% { opacity: 1.0; }
50% { opacity: 0.0; }
100% { opacity: 1.0; }
}
#keyframes blinker {
0% { opacity: 1.0; }
50% { opacity: 0.0; }
100% { opacity: 1.0; }
}
As commented by jCuber, if you want to start animation at 50% than try this
Demo

try this i made some changes in your fiddle it's work and also link of new fiddle
<div class="blink_me"> Blink</div>
.blink_me {
animation-name: blinker;
animation-duration: 5s;
animation-iteration-count: infinite;
-webkit-animation-name: blinker;
-webkit-animation-duration: 5s;
-webkit-animation-iteration-count: infinite;
background:#ff0000;
border:1px solid #00ff00;
}
#-webkit-keyframes blinker {
0% {width:20px; opacity: 0;}
50% {width:20px; opacity: 1; }
100% {width:50px; opacity: 0; }
}
http://jsfiddle.net/umz8t/293/

it looks like you just made a simple mistake the last line should read 100% not 50%. It could actually read anything between 51% to 100%. You also were missing a semi-colon, added it in.
#-webkit-keyframes myfirst /* Safari and Chrome */
{
0% { height:200px; }
50% {opacity:1; }
100% {height:300px; opacity: 0; }
}

Related

CSS Iteration count and stop code not working

How can I make this loop once, and then it remain as written unless page is reloaded? I tried many things I read. Could you please amend the code so I can see where you're inserting it?
Simply what i'm trying is to make it appear once, then remain until the page is reloaded or something.
Thank you!
I sincerely appreciate it.
#import url('https://fonts.googleapis.com/css?family=Roboto:300');
body {
text-align:center;
background:none;
color:white;
font-family:'Roboto';
font-weight:300;
font-size:32px;
padding-top:5vh;
height:100vh;
overflow:hidden;
-webkit-backface-visibility: hidden;
-webkit-perspective: 1000;
-webkit-transform: translate3d(0,0,0);
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
div {
display:inline-block;
overflow:hidden;
white-space:nowrap;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
div:first-of-type { /* For increasing performance
ID/Class should've been used.
For a small demo
it's okaish for now */
animation: showup 10s 1;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
div:last-of-type {
width:0px;
animation: reveal 10s 1;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
div:last-of-type span {
margin-left:-355px;
animation: slidein 10s 1;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
#keyframes showup {
0% {opacity:0;}
20% {opacity:1;}
80% {opacity:1;}
100% {opacity:0; animation-iteration-count: 1; animation-fill-mode: forwards;}
}
#keyframes slidein {
0% { margin-left:-800px; }
20% { margin-left:-800px; }
35% { margin-left:0px; }
100% { margin-left:0px; animation-iteration-count: 1; animation-fill-mode: forwards;}
}
#keyframes reveal {
0% {opacity:0;width:0px;}
20% {opacity:1;width:0px;}
30% {width:355px;}
80% {opacity:1;}
100% {opacity:1;width:355px; animation-iteration-count: 1; animation-fill-mode: forwards;}
}
#keyframes grow {
0% { font-size: 0; }
100% { font-size: 40px; animation-iteration-count: 1; animation-fill-mode: forwards; }
}
p {
font-size:12px;
color:white;
margin-top:200px;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
<div>Escape</div>
<div>
<span>into amazing experiences</span>
</div>
The showup keyframe ends in 0 opacity.
#import url('https://fonts.googleapis.com/css?family=Roboto:300');
body {
text-align:center;
background:none;
color:red;
font-family:'Roboto';
font-weight:300;
font-size:32px;
padding-top:5vh;
height:100vh;
overflow:hidden;
-webkit-backface-visibility: hidden;
-webkit-perspective: 1000;
-webkit-transform: translate3d(0,0,0);
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
div {
display:inline-block;
overflow:hidden;
white-space:nowrap;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
div:first-of-type { /* For increasing performance
ID/Class should've been used.
For a small demo
it's okaish for now */
animation: showup 10s 1;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
div:last-of-type {
width:0px;
animation: reveal 10s 1;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
div:last-of-type span {
margin-left:-355px;
animation: slidein 10s 1;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
#keyframes showup {
0% {opacity:0;}
20% {opacity:1;}
80% {opacity:1;}
100% {opacity:1; animation-iteration-count: 1; animation-fill-mode: forwards;}
}
#keyframes slidein {
0% { margin-left:-800px; }
20% { margin-left:-800px; }
35% { margin-left:0px; }
100% { margin-left:0px; animation-iteration-count: 1; animation-fill-mode: forwards;}
}
#keyframes reveal {
0% {opacity:0;width:0px;}
20% {opacity:1;width:0px;}
30% {width:355px;}
80% {opacity:1;}
100% {opacity:1;width:355px; animation-iteration-count: 1; animation-fill-mode: forwards;}
}
#keyframes grow {
0% { font-size: 0; }
100% { font-size: 40px; animation-iteration-count: 1; animation-fill-mode: forwards; }
}
p {
font-size:12px;
color:white;
margin-top:200px;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
<div>Escape</div>
<div>
<span>into amazing experiences</span>
</div>

How can I make fade out text

This is my first question on this platform.
I am trying to make anki card that shows a question for a number of seconds then I need it to fade out.
this is the code that I have found.
#-webkit-keyframes fadeIn {
100%,0%{opacity:.5;}
0%,0%{opacity:1;}
}
.fade-out {
font-size:20px;
color: dodgerblue;
background:white;
padding:10px;
opacity:0;
-webkit-animation:fadeIn ease-in 1;
-webkit-animation-fill-mode:forwards;
-webkit-animation-duration:2s;
-webkit-animation-delay:4s;
This kind of stuff is usually easy to just google, but anyways this is a solution that will work perfectly
.fader {
animation: fadeOut ease 8s;
-webkit-animation: fadeOut ease 8s;
-moz-animation: fadeOut ease 8s;
-o-animation: fadeOut ease 8s;
-ms-animation: fadeOut ease 8s;
}
#keyframes fadeOut {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
#-moz-keyframes fadeOut {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
#-webkit-keyframes fadeOut {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
#-o-keyframes fadeOut {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
#-ms-keyframes fadeOut {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
<h1 class="fader">
Hey!
</h1>
You can make an animation with the #keyframes tag. For instance
#keyframes fade-out {
100%{
opacity: 0%;
}
}
and then also in your CSS you have something like this:
.your-class{
animation: fade-out 3s linear 10s 1;
animation-fill-mode: forwards;
}
And then in your HTML you have this:
<div class="your-class">What is 1+1?</div>
The values in the CSS mean that the "fade-out" animation will be played in a 3s time and a linear animation. The 10s mean that after 10s the animation will play, so it means that the card will disappear after 10s. and the "1" means it will only play 1 time, this is optional since 1 is the default value.
animation-fill-mode means that the value that's in the animation (opacity: 0%) will remain and only goes away when you refresh the page for instance. It will overtake the default value which is normally 100%;
Hoped this helped you.

CSS animation delay (img display time)

I've got this CSS:
#-webkit-keyframes sliderFadeInOut {
0% {
opacity:1;
}
17% {
opacity:1;
}
25% {
opacity:0;
}
92% {
opacity:0;
}
100% {
opacity:1;
}
}
#-moz-keyframes sliderFadeInOut {
0% {
opacity:1;
}
17% {
opacity:1;
}
25% {
opacity:0;
}
92% {
opacity:0;
}
100% {
opacity:1;
}
}
#-o-keyframes sliderFadeInOut {
0% {
opacity:1;
}
17% {
opacity:1;
}
25% {
opacity:0;
}
92% {
opacity:0;
}
100% {
opacity:1;
}
}
#keyframes sliderFadeInOut {
0% {
opacity:1;
}
17% {
opacity:1;
}
25% {
opacity:0;
}
92% {
opacity:0;
}
100% {
opacity:1;
}
}
#slider {
background-size: cover;
position: fixed;
top: 100px;
bottom: 0px;
height:calc(100%-135px);
width: 100%;
}
#slider img {
border: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
margin: 0px;
width: 100%;
height: 100%;
position:absolute;
left:0;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
#slider img {
-webkit-animation-name: sliderFadeInOut;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-iteration-count: infinite;
-webkit-animation-duration: 10s;
-moz-animation-name: sliderFadeInOut;
-moz-animation-timing-function: ease-in-out;
-moz-animation-iteration-count: infinite;
-moz-animation-duration: 8s;
-o-animation-name: sliderFadeInOut;
-o-animation-timing-function: ease-in-out;
-o-animation-iteration-count: infinite;
-o-animation-duration: 8s;
animation-name: sliderFadeInOut;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-duration: 8s;
}
#slider img:nth-of-type(1) {
-webkit-animation-delay: 6s;
-moz-animation-delay: 6s;
-o-animation-delay: 6s;
animation-delay: 6s;
}
#slider img:nth-of-type(2) {
-webkit-animation-delay: 4s;
-moz-animation-delay: 4s;
-o-animation-delay: 4s;
animation-delay: 4s;
}
#slider img:nth-of-type(3) {
-webkit-animation-delay: 2s;
-moz-animation-delay: 2s;
-o-animation-delay: 2s;
animation-delay: 2s;
}
#slider img:nth-of-type(4) {
-webkit-animation-delay: 0;
-moz-animation-delay: 0;
-o-animation-delay: 0;
animation-delay: 0;
}
I'm learning CSS Animations, but I didn't find out how to set the display time of one image.
I tried to change the animation delay but that only causes trouble..
Do you have an idea how to do this ?
Best regards
There were several things that needed some attention. Here's how I accomplished it, though there are other ways.
For the animation itself:
#keyframes sliderFadeInOut {
0% {
opacity:0;
}
17% {
opacity:1;
}
25% {
opacity:1;
}
92% {
opacity:1;
}
100% {
opacity:0;
}
}
This causes the image to fade in, then fade out at whatever animation-duration we set.
Set the animation-iteration-count to 1, so the animation runs once.
animation-iteration-count: 1;
Each image in the stack needs to be timed to appear, then disappear as the next image in the stack becomes visible. To do this, use animation-delay and increase it for each image in the stack.
#slider img:nth-child(1) {
animation-delay: 0s;
}
#slider img:nth-child(2) {
animation-delay: 4s;
opacity:0;
}
#slider img:nth-child(3) {
animation-delay: 8s;
opacity:0;
}
#slider img:nth-child(4) {
animation-delay: 12s;
opacity:0;
}
The staggered animation-delay properties cause the first image in the stack to be shown initially. It's animation takes 5 seconds and results in the image disappearing. At 4 seconds, the 2nd image in the stack starts it's animation, appearing just as the first image is disappearing. And then so on for the 3rd and 4th images.
In the code above there's also an initial opacity property for the 2nd, 3rd and 4th images. This is necessary to hide them initially.
As it's setup now the images will loop only once. Some minor tweaking to animation-delay and animation-iteration-count would cause it to loop infinitely.
Here's the working demo.

Applying css animation to div

I've created a div with a background image in css and I want the div/image to have an automatic fade in and fade out effect.
I've gathered the css animation for this to work however I have no idea as to how I can combine the css of the animation with my current div's css. So here is what I have so far
HTML
<div id="image"></div>
CSS
div.image {
content:url(http://www.google.com/images/srpr/logo3w.png);
float:left;
}
Animation CSS
#-webkit-keyframes blink {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-moz-keyframes blink {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-o-keyframes blink {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
img {
-webkit-animation: blink 1s;
-webkit-animation-iteration-count: infinite;
-moz-animation: blink 1s;
-moz-animation-iteration-count: infinite;
-o-animation: blink 1s;
-o-animation-iteration-count: infinite;
}
You need to target the div with the background image.
#image targets <div id="image">
.image targets <div class="image">
img targets <img>
You can read more on CSS selectors over at MDN.
Have an example!
CSS
#image {
-webkit-animation: blink 3s;
-webkit-animation-iteration-count: infinite;
-moz-animation: blink 3s;
-moz-animation-iteration-count: infinite;
-o-animation: blink 3s;
-o-animation-iteration-count: infinite;
}
You should also specify a background-image instead of using content:
Note: If there is no content in your div you need to specify a width and height in order to see the background image. By default, the image will be repeated - using no-repeat will have the image only displayed once. Read more on CSS backgrounds here.
Same example but with a background image.
div#image {
background:url(http://www.google.com/images/srpr/logo3w.png) no-repeat;
height: 95px;
width: 280px;
float:left;
}
You have some errors in your CSS.
Your div have id="image". But you selected div.image instead of div#image
You applied the animation property on img instead on your div.
The proper CSS would be
div#image {
content:url(http://www.google.com/images/srpr/logo3w.png);
float:left;
-webkit-animation: blink 1s;
-webkit-animation-iteration-count: infinite;
-moz-animation: blink 1s;
-moz-animation-iteration-count: infinite;
-o-animation: blink 1s;
-o-animation-iteration-count: infinite;
}
#-webkit-keyframes blink {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-moz-keyframes blink {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-o-keyframes blink {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
Here is a DEMO
A part of your css code if for the <blink> element and it works if you change it accordingly.
Take a look at my example on jsfiddle.

<p> tag won't stay on hovered state even when hovering over it

I have a <p> tag, and when I hover over it I want it to play an animation with #keyframes. It does the animation perfectly, but when the animation has finished, it will revert back to the state before the hovering. Does anyone know what I'm doing wrong?
EDIT: If you'd rather use a fiddle, check this out.
The reason why the buttons flash red is purely for testing reasons.
My HTML is as follows:
<div id="imgOver9" class="imgOver">
<p id="pLink9" class="pLink" href="home.html">Chillin', relaxin', maxin' all cool and shootin' some b-ball outside of school</p>
</div>
Here is the CSS for the <p> element:
.pLink{
position:absolute;
left:1vw;
top:-1vw;
height:24vw;
width:24vw;
opacity:0;
text-align:justify;
display:block;
font-family: 'Antic Didone', 'serif';
z-index:1;
background-color:red;
font-size:2vw;
}
.pLink:hover{
animation: pLink linear 0.1s;
animation-iteration-count: 1;
transform-origin:;
-webkit-animation: pLink linear 0.1s;
-webkit-animation-iteration-count: 10;
-webkit-transform-origin: ;
-moz-animation: pLink linear 0.1s;
-moz-animation-iteration-count: 1;
-moz-transform-origin: ;
-o-animation: pLink linear 0.1s;
-o-animation-iteration-count: 1;
-o-transform-origin: ;
-ms-animation: pLink linear 0.1s;
-ms-animation-iteration-count: 1;
-ms-transform-origin: ;
}
#keyframes pLink{
0% {
opacity:0;
color:#000000
}
100% {
opacity:1;
color:#8C8C96;
}
}
#-moz-keyframes pLink{
0% {
opacity:0;
color:#000000
}
100% {
opacity:1;
color:#8C8C96;
}
}
#-webkit-keyframes pLink {
0% {
opacity:0;
color:#000000
}
100% {
opacity:1;
color:#8C8C96;
}
}
#-o-keyframes pLink {
0% {
opacity:0;
color:#000000
}
100% {
opacity:1;
color:#8C8C96;
}
}
#-ms-keyframes pLink {
0% {
opacity:0;
color:#000000
}
100% {
opacity:1;
color:#8C8C96;
}
}
And here is the CSS for the parent div:
.imgOver{
opacity:0%;
width:26vw;
height:26vw;
}
.imgOver:hover{
animation: imgOver linear 0.1s;
animation-iteration-count: 1;
transform-origin: ;
-webkit-animation: imgOver linear 0.1s;
-webkit-animation-iteration-count: 1;
-webkit-transform-origin: ;
-moz-animation: imgOver linear 0.1s;
-moz-animation-iteration-count: 1;
-moz-transform-origin: ;
-o-animation: imgOver linear 0.1s;
-o-animation-iteration-count: 1;
-o-transform-origin: ;
-ms-animation: imgOver linear 0.1s;
-ms-animation-iteration-count: 1;
-ms-transform-origin: ;
}
#keyframes imgOver{
0% {
opacity:0;
}
100% {
opacity:1;
}
}
#-moz-keyframes imgOver{
0% {
opacity:0;
}
100% {
opacity:1;
}
}
#-webkit-keyframes imgOver {
0% {
opacity:0;
}
100% {
opacity:1;
}
}
#-o-keyframes imgOver {
0% {
opacity:0;
}
100% {
opacity:1;
}
}
#-ms-keyframes imgOver {
0% {
opacity:0;
}
100% {
opacity:1;
}
}
I have been going over this for hours now, and I cannot find the flaw. I would be very grateful for whoever manages to solve my issue.
You will need to use animation: pLink 0.1s forwards; in order to keep the final state of the animation.
Here is a demo fiddle