How to stop progress bar animation? [duplicate] - html

This question already has answers here:
Maintaining the final state at end of a CSS animation
(5 answers)
Closed 4 years ago.
I tried to figure out this issue. How do I stop the progress bar after the animation ends?
ul li {list-style:none;}
li {width:100%;height:30%;background-color:#ccc;margin-top:20px;position:relative;}
.skillsBar ul li .bar{
animation: Ani linear 7s 1 normal;background-color:#f00;height: 100%; position: absolute; top:0;
}
.skillsContWrpa .skillsBar ul li .bar{
animation-name:Ani;
animation-duration: 7s;
animation-iteration-count: 1;
animation-timing-function: ease;
animation-direction: alternate;
animation-fill-mode: both;
}
#keyframes Ani {
0% { width:0%; }
100% { width:90%; }
}
<div class="skillsBar">
<ul>
<li><span>PHOTOSHOP 90%</span>
<div class="bar"></div>
</li>
<li><span>HTML CSS 80%</span></li>
<li><span>DEVELOPMENT 70%</span></li>
<li><span>MARKETING 80%</span></li>
</ul>
</div>

add "animation-fill-mode: forwards;" to your css class ".bar"
forward -> The element will retain the style
ul li {list-style:none;}
li {width:100%;height:30%;background-color:#ccc;margin-top:20px;position:relative;}
.bar{
background-color:#f00;
height: 100%;
position: absolute;
top:0;
animation: Ani linear 7s normal;
animation-fill-mode: forwards;
}
#keyframes Ani {
0% { width:0%; }
100% { width:90%; }
}
<div class="skillsBar">
<ul>
<li>
<span>PHOTOSHOP 90%</span>
<div class="bar"></div>
</li>
<li><span>HTML CSS 80%</span></li>
<li><span>DEVELOPMENT 70%</span></li>
<li><span>MARKETING 80%</span></li>
</ul>
</div>
values that is set by the last keyframe.

I think this is what you are looking for: Solution to your question - Codepen link
You have to use this basic structure:
<div class="skillbar clearfix javascript" data-percent="80%">
<h4 class="skillbar-title"><span>Development</span></h4>
<div class="skillbar-bar"></div>
<div class="skill-bar-percent">80%</div>
</div>
Inside data-percent="" you can put any percentage and animation will work accordingly.

Related

CSS3 Using nth-type and animation delay

It's possible using nth-type add delay for each image in a list?
in my example I want that each image appears with a different delay, by example, the 1st appears with a .5 delay, the 2nd 1s and so on in each group of 4 images.
Example in this codepen: http://codepen.io/gpincheiraa/pen/eJeEmb
EDIT:
More detailed description that i want to do
Iteration 1:
|-- first image of Li moff-1 delayed 0.5|-- first image of Li moff-2 delayed 1s --| ...
Iteration 2:
|-- second image of Li moff-1 delayed 0.5|-- second image of Li moff-2 delayed 1s --| ...
Iteration 3:
|-- third image of Li moff-1 delayed 0.5|-- third image of Li moff-2 delayed 1s --| ...
and so on ...
HTML
<ul class="services-images">
<li class="moff-1">
<img src="http://estudiodelacruz.cl/insitu/insitu/images/making-off-03.jpg">
<img src="http://estudiodelacruz.cl/insitu/insitu/images/making-off-11.jpg">
<img src="http://estudiodelacruz.cl/insitu/insitu/images/making-off-07.jpg">
</li>
<li class="moff-2">
<img src="http://estudiodelacruz.cl/insitu/insitu/images/making-off-12.jpg">
<img src="http://estudiodelacruz.cl/insitu/insitu/images/making-off-02.jpg">
<img src="http://estudiodelacruz.cl/insitu/insitu/images/making-off-08.jpg">
</li>
<li class="moff-3">
<img src="http://estudiodelacruz.cl/insitu/insitu/images/making-off-01.jpg">
<img src="http://estudiodelacruz.cl/insitu/insitu/images/making-off-10.jpg">
<img src="http://estudiodelacruz.cl/insitu/insitu/images/making-off-06.jpg">
</li>
<li class="moff-4">
<img src="http://estudiodelacruz.cl/insitu/insitu/images/making-off-05.jpg">
<img src="http://estudiodelacruz.cl/insitu/insitu/images/making-off-09.jpg">
<img src="http://estudiodelacruz.cl/insitu/insitu/images/making-off-04.jpg">
</li>
</ul>
CSS
.services-images, .contact-images {
position: relative;
display: flex;
min-height: 200px;
}
.services-images img{
position: absolute;
top:0;
left:0;
padding: 0 10px;
}
.services-images li{
width: 25%;
position: relative;
}
.services-images img:nth-of-type(1){
-webkit-animation: fadeInOut 9s linear 9s infinite;
}
.services-images img:nth-of-type(2){
-webkit-animation: fadeInOut 9s linear 6s infinite;
}
.services-images img:nth-of-type(3){
-webkit-animation: fadeInOut 9s linear 3s infinite;
}
.services-images img:nth-of-type(4){
-webkit-animation: fadeInOut 9s linear infinite;
}
#-webkit-keyframes fadeInOut{
0% { opacity:1; }
17% { opacity:1; }
25% { opacity:0; }
92% { opacity:0; }
100% { opacity:1; }
}

How to use fade-in text/image on page is loaded

I'm building a small website and would like to get the text (and an image when I add one) to fade in when someone accesses the website?
Thanks!
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<style>
body {
background-color: lightgrey;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover:not(.active) {
background-color: #111;
}
.active {
background-color: #4CAF50;
}
</style>
<style>
p.one {
border: 1px lightgrey;
background-color: lightgrey;
padding-top: 50px;
padding-right: 30px;
padding-bottom: 40px;
padding-left: 0px;
}
IMG.displayed {
display: block;
margin-left: auto;
margin-right: auto
}
</style>
</head>
<body>
<ul>
<li><a class="active" href="#home">Home</a></li>
<li>Our Routes</li>
<li>Contact</li>
<li>About</li>
</ul>
<img class="displayed" src="E:\Users\PC\Documents\Image" alt="...">
<h1 align="center"> HOME </h1>
<p class="one" , align="center"> Text Goes here
</p>
</body>
</html>
http://codepen.io/JTBennett/pen/GorVRL [your site w/ fade and motion]
http://codepen.io/JTBennett/pen/BjpXRo [example of the following instructions]
Here's an example. The HTML requires a div to be wrapped around the whole of the body content if you want it to fade in all at once. Look for this:
<div class="wrapper fade-in">
There's a lot of stuff you can do with CSS, I've been using it for years and I still learn something new every once in a while.
All the animation commands will appear in your CSS like so:
#keyframes fadeIn
to {
opacity: 1; }
Then your divs are going to have a class that calls the animation (#keyframes):
.fade-in {
animation: fadeIn 1.0s ease forwards;
[other div properties can be included here]
}
The HTML will look like this:
<div class="fade-in">
[content]
</div>
Finally, you'll need to make sure you include the vendor codes to make it compatible with all browsers [which adds a fair amount of code, which is why jQuery can be a better option for this stuff]:
#keyframes fadeIn{
0% {
opacity:0;
}
100% {
opacity:1;
}
}
#-moz-keyframes fadeIn {
0% {
opacity:0;
}
100% {
opacity:1;
}
}
#-webkit-keyframes fadeIn {
0% {
opacity:0;
}
100% {
opacity:1;
}
}
#-o-keyframes fadeIn {
0% {
opacity:0;
}
100% {
opacity:1;
}
}
#-ms-keyframes fadeIn {
0% {
opacity:0;
}
100% {
opacity:1;
}
}
The vendor codes will have to be duplicated again in your div class in the CSS:
.fade-in {
animation: fadeIn ease 5s;
-webkit-animation: fadeIn ease 5s;
-moz-animation: fadeIn ease 5s;
-o-animation: fadeIn ease 5s;
-ms-animation: fadeIn ease 5s;
}
The effect can be achieved with jQuery much quicker, as you can see in one of the other answers here.
After you've learned to do it by hand, I suggest playing around with this CSS3 animation generator if you want to save a bit of time:
http://cssanimate.com/
Just make sure you understand it first though.
Lastly, this is an example of jQuery performing similar functions (though using SVGs instead of divs this time, same process though):
http://codepen.io/JTBennett/pen/YwpBaQ
I don't know what element you have but you can do a few things.
If you are using javascript, or jquery you can make an element fade in easily.
Jquery:
$(document).ready(function(){
$('.myItemClass').fadeIn();
});
You can also do it with just CSS
CSS:
/* The animation code */
#keyframes example {
from {opacity: 0;}
to {opacity: 1;}
}
.myClass {
animation-name: example;
animation-duration: 1s;
}
You can fade in elements when the document loads by loading the page with the elements hidden (opacity : 0;) in CSS. Then on document ready you can remove the class, so long as it has a transition for that css property—you'll have an effect.
CSS
div {
transition: opacity 2s;
opacity: 1;
}
.hidden {
opacity: 0;
}
JS
$(document).ready(function(){
$('.hidden').removeClass('hidden');
});
It is very simple don't need even jqyery, pure CSS and pure Javascript.
CSS
body {
opacity:0;
transition: 300ms opacity;
}
Javascript
function pageLoaded() {
document.querySelector("body").style.opacity = 1;
}
window.onload = pageLoaded;

CSS - Cross fading with multiple images on a webpage

I have referred to this guide in order to attempt to get a series of images that display on the screen one after another on my website. On the guide i'm using Demo 3 and I've matched all the code from Demo 3 of the guide to suit my chosen images on my page. However for some reason the image on my page doesn't seem to be fading to the other image after a short time. I was wondering if anyone could point me in the right direction so my code is working like the one on demo 3 of the guide
Here is the HTML content for the page including the two images used:
<!--INDEX CONTENT-->
<div id="index_banner">
<img class="bottom" src="images/SPAWN IMAGE.png" alt="INDEX BANNER">
<img class="top" src="images/SURVIVAL IMAGE - GAMEMODES.png" alt="INDEX BANNER 2">
</div>
<div id="welcome_text">
<h3>Welcome to CRAFT412</h3>
<h3>We are currently running version 1.8.1</h3>
<h3>Survival / PurePVP / GamesWorld</h3>
</div>
<div id="trailer_title">
<h4><br>SERVER TRAILER</h4>
</div>
<div id="trailer_video">
<iframe width="832" height="468" src="http://www.youtube.com/embed/dfbWw757Iow"></iframe>
</div>
</div>
And here is the CSS:
/*INDEX PAGE CSS*/
#index_banner {height:360px;
position:relative;
margin:0 auto;}
#index_banner img {position:absolute;
-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;}
#keyframes cf3FadeInOut {
0% {
opacity:1;
}
45% {
opacity:1;
}
55% {
opacity:0;
}
100% {
opacity:0;
}
}
#index_banner img.top {
animation-name: cf3FadeInOut;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-duration: 10s;
animation-direction: alternate;
}
#welcome_text {padding-top: 20px;
text-align: center;
line-height: 2em;}
#trailer_title {text-align: center;}
#trailer_video {padding-top: 10px;
text-align: center;
padding-bottom:20px;}
the #keyframe rule works inside the animation property;
and you're not defining the animation property anywhere,
so to begin addanimation: cf4FadeInOut 8s; to #index_banner img selector.

Animation delay property to change content at fixed intervals

I am trying to animate two pictures so that they change at fixed intervals but the problem is that the second image appears quickly and fades I need a way to make the delay property to repeat i have refereed this but that doesn't seem to work CSS animation delay in repeating
http://jsfiddle.net/fc3nb5rL/2/
I think my problem is somewhere here
#-webkit-keyframes anim {
from {
z-index:1;
}
to {
z-index:-2;
}
}
.back {
-webkit-animation:anim 5s;
-webkit-animation-iteration-count:infinite;
-webkit-animation-timing-function: ease-in-out;
}
#-webkit-keyframes anim2 {
from {
z-index:1;
}
to {
z-index:-2;
}
}
First fix your HTML(markup), then you can animate the opacity and not the z-index
.container {
position:relative;
height:500px;
width:500px;
margin:0 auto;
}
.container img {
position:absolute;
width:100%;
}
#-webkit-keyframes anim1 {
from {
opacity:0;
}
to {
opacity:1;
}
}
#-webkit-keyframes anim2 {
from {
opacity:1;
}
to {
opacity:0;
}
}
[href=first] img {
opacity:0;
/*animation----:----name--duration--delay--timing function---direction----iteration count*/
-webkit-animation: anim1 2s 0s linear alternate infinite;
}
[href=second] img {
opacity:1;
-webkit-animation: anim2 2s 0s linear alternate infinite;
}
<div class="container">
<a href="second">
<img src="http://placekitten.com/300/300" />
</a>
<a href="first">
<img class="front" src="http://placekitten.com/300/301" />
</a>
</div>
Give this a shot. I have also set it up to be cross-browser compatible. http://jsfiddle.net/fc3nb5rL/2/
A few things to note about CSS3 transitions. It does not know how to interpolate between the z-index
property, as well as the display property.

Hover Animation won't disappear when not hovering

I have a div I've animated on hover. However when I am not hovering the div won't disappear
This is what the entire thing looks like in action: http://jsfiddle.net/Vbxtc/
This is the html:
<nav>
<div id="controls">
<button id="playButton">Play</button>
<div id="defaultBar">
<div id="progressBar"></div>
</div>
<button id="vol" onclick="level()">Vol</button>
<button id="mute">Mute</button>
<button id="full" onclick="toggleFullScreen()">Full</button>
</div>
<div id="playlist" class="animated fadeInRight">
<div>cats</div>
<div>cats</div>
<div>cats</div>
</div>
</nav>
This is the CSS i've made:
#playlist{
position:absolute;
display:block;
border:1px solid red;
height: 82%;
width: 25%;
top: 20px;
right: 0px;
z-index: 2;
float:right;
padding: 0px;
margin: 0px;
color:white;
background-color:#999999;
opacity: 0;
}
#playlist:hover {
opacity: 1;
}
This is the animation im trying
.animated:hover {
-webkit-animation-fill-mode: both;
-moz-animation-fill-mode: both;
-ms-animation-fill-mode: both;
-o-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-duration: 1s;
-moz-animation-duration: 1s;
-ms-animation-duration: 1s;
-o-animation-duration: 1s;
animation-duration: 1s;
}
.fadeInRight {
-webkit-animation-name: fadeInRight;
-moz-animation-name: fadeInRight;
-o-animation-name: fadeInRight;
animation-name: fadeInRight;
}
#-webkit-keyframes fadeOutRight {
0% {
opacity: 1;
-webkit-transform: translateX(0);
}
100% {
opacity: 0;
-webkit-transform: translateX(20px);
}
}
#-webkit-keyframes fadeInRight {
0% {
opacity: 0;
-webkit-transform: translateX(20px);
}
100% {
opacity: 1;
-webkit-transform: translateX(0);
}
}
I noticed that when you time the mouse over exactly right (hover for about 1 second and move mouse up top), it DOES fade out nicely.
The other thing is, if you add the class fadeOutRight as follows:
<div id="playlist" class="animated fadeInRight fadeOutRight">
It fades out too quickly.
I know I didn't help much but the answer lies in the timing.
Also, if you had the fadeOutRight class on, for example, the sidebar, it works nicely!
<aside id="sidebar" class="fadeOutRight">
Perhaps, put the class of fadeOutRight on everything EXCEPT the fadeInRight div.
It's not a good idea to play with an element position in the hover state.
Even if you get to program it right (that is not easy), most of the time the user won't understand what's happening.
You can get flickering scenarios where, without the user moving the cursor, your div leaves the cursor position, canceling the hover, the div re-entering the cursor, the hover triggering , and so on.
I would recomend to trigger the hover on another div that covers the full area where the moving div will be.