When using ''@keyframe play'' in css, how can you get the frame the animation is currently at with javascript?
Get the element you would like to get the current background-position
for, and use:
getComputedStyle(element).getPropertyValue("background-position");
I might recommend recoding it to use JavaScript however, since it will be more efficient to interact with programmatically, and there won't be any noticeable performance hit in modern browsers if you use requestAnimationFrame
based animation.
More information about getComputedStyle
on MDN.
Seek to specific keyframe in css3 animation
You can seek to a specific keyframe by using a negative animation-delay value.
How to transition CSS display + opacity properties
Based on Michaels answer this is the actual CSS code to use
.parent:hover .child
{
display: block;
-webkit-animation: fadeInFromNone 0.5s ease-out;
-moz-animation: fadeInFromNone 0.5s ease-out;
-o-animation: fadeInFromNone 0.5s ease-out;
animation: fadeInFromNone 0.5s ease-out;
}
@-webkit-keyframes fadeInFromNone {
0% {
display: none;
opacity: 0;
}
1% {
display: block;
opacity: 0;
}
100% {
display: block;
opacity: 1;
}
}
@-moz-keyframes fadeInFromNone {
0% {
display: none;
opacity: 0;
}
1% {
display: block;
opacity: 0;
}
100% {
display: block;
opacity: 1;
}
}
@-o-keyframes fadeInFromNone {
0% {
display: none;
opacity: 0;
}
1% {
display: block;
opacity: 0;
}
100% {
display: block;
opacity: 1;
}
}
@keyframes fadeInFromNone {
0% {
display: none;
opacity: 0;
}
1% {
display: block;
opacity: 0;
}
100% {
display: block;
opacity: 1;
}
}
Related Topics
A Singleton List of List Is Automatically Decomposed
Correct Way for Writing an <Address> Tag for My Web Site, to Provide Contact Details for Our Company
How to Make Bootstrap Table Rows Clickable
Making HTML Content Unbreakable (In One Line)
Twitter Bootstrap Modal Width Issues
CSS3/HTML 5/Png Blur Content Behind Element
4 Columns Elastic CSS with Top-Left Box Spanning 2 Columns. How
Stylesheet Not Parsed Because Non CSS Mime Types Are Not Allowed in Strict Mode
Border Collapse Differences in Ff and Webkit
Change in Doctype Causes Webpage to Render Differently
Avoid an Image to Go Outside a Div
Split Page Vertically Using CSS
Distributing Images Evenly & Horizontally in a Div via CSS
Calculating Background-Position with a Formula in Less CSS
Styling Input Range for Webkit with Pure CSS
Three Column Div Layout Dynamics; Left = Fixed, Center = Fluid, Right = Fluid