This HTML element had a nice transition effect when it was clicked. However when I added another class with animation property, transition was lost. Look at the demo: http://codepen.io/kunokdev/pen/rewveJ
<div
class="main-menu-item zoom-in-entrance">
Test
</div>
Do animation and transition properties not stack?
#keyframes zoom-in-entrance
from
opacity: 0
-webkit-transform: scale3d(.3, .3, .3)
transform: scale3d(.3, .3, .3)
50%
opacity: 1
.zoom-in-entrance
-webkit-animation: zoom-in-entrance .25s forwards
animation: zoom-in-entrance .25s forwards
.main-menu-item
cursor: pointer
background: $white
transition: all .25s
&:active
+scale(0.95,0.95)
i, span
display: block
Animation from animation property only happens on page load and never again, however animation from transition happens only when an element is clicked.
How do I make them both work?
Both your animation and transition properties are trying to affect scale. This is because you have specified forwards as the animation fill mode.
Since your animation ends on the "default" state of the item, you can use none instead, and the animation will not hold the scale at 1.0, allowing the transition to take effect:
-webkit-animation: zoom-in-entrance .25s none
animation: zoom-in-entrance .25s none
(you can also just leave out none as it's the default fill mode)
Updated pen: http://codepen.io/anon/pen/XdgqNq
If you remove the forwards which persits the final state of the animation it works fine.
If you can use js, you could remove zoom-in-entrance class after animation is finished.
Callback when CSS3 transition finishes
Related
How to create this kind of css animation where element fades in from the bottom but appears like clipped with overflow:
http://fr.creasenso.com/ (see the breadcrumb text)
I've tried all the basics but not going anywhere with translateY. Do I need to go to libraries or is it achievable with css only?
The wording of your question could use some improvement. But besides that, I think this is what you are looking for:
https://jsfiddle.net/5ws33c8s/
You need a parent element which has a overflow: hidden. Followed by the childs which are moved out using translate: translateY().
I then used css keyframes to move it back in:
animation: fadeInText 300ms 0ms forwards;
#keyframes fadeInText {
from {
transform: translateY(30px);
opacity: 0;
} to {
transform: translateY(0);
opacity: 1;
}
}
This animation is set up as follows; fadeInText is the keyframes name, 300ms is the duration of the animation, 0ms is the delay of said animation and forwards remembers the final state of the animation, and leaves the element as such. Without it, the element would jump back to its original values.
I then used a delay on each child element.
span:nth-child(2) {
animation-delay: 150ms;
}
I have a list of elements, which when hovered over show a set of controls to remove them. The controls transition in with opacity values.
.duplicate-controls {
position: relative;
float: left;
opacity: 0;
transition: opacity linear 0.7s; }
.duplicate-group:hover .duplicate-controls {
opacity: 1;
transition: opacity linear 0.7s; }
When I'm animating the content, it'll skip or interrupt the animation in a jarring fashion. If I remove the opacity transitions, i can't reproduce the issue.
Please see the following gif for a visual representation of what i'm talking about.
This is it interrupting.
http://gfycat.com/IncomparableBlaringAsianporcupine
This is how it should animate.
http://gfycat.com/CheapMajesticBluebottlejellyfish
Remove the transition property from
.duplicate-group:hover .duplicate-controls{}
I have the following situation: I have an element .animated-container which is invisible by default. When it gets an additional .is-visible class the element fades in with a slight move from the top. That is fine so far. Now my problem is, that the exit animation should be without the slight move back to the top which currently leads to a jump of my element.
The enter transition looks like this:
.is-visible {
transition: opacity .2s, margin-top .4s;
opacity: 1;
visibility: visible;
margin-top: 0;
}
and the exit transition like this:
.animated-container {
/* ... */
transition: opacity .2s, visibility .2s;
margin-top: -60px;
opacity: 0;
visibility: hidden;
}
Having my code like this makes my element jump since margin-top is not animated when removing the .is-visible class.
See my current code here
Thank you so much for every upcoming answer!
Just add a margin-top transition with a delay that lasts the duration of the other animations..
This way it will wait for the other transitions to finish and then try the margin-top (which you do not care about since it will already be invisible.)
.animated-container{
/*...*/
transition: opacity .2s, visibility .2s, margin-top 0s .2s;
}
Demo at http://codepen.io/gpetrioli/pen/xbbavJ
I was wondering if it was possible to state an unhover class at all on an image?
What I am trying to achieve is when someone hovers over an image it will fade in and then when they unhover it fades back out?
Heres my code, I got the fade in to work when someone hovers over an image but I need it too fade out when they unhover... hope this made sense.
http://jsfiddle.net/L7XCD/
This should work for you! http://jsfiddle.net/L7XCD/1/
Let's use the great mozilla documentation to explain this:
Transition rovide a way to control the speed of animation changes to CSS properties. Instead of having the animation changes take effect instantly, you can transition the property changes over a specified time period.
Also we used the transition timing functions (ease, linear, easy-in, easy-out, easy-in-out)
Timing functions determine how intermediate values of the transition are calculated. The timing function can be specified by providing the graph of the corresponding function, as defined by four points defining a cubic bezier
CCS markup:
img {
opacity: 0.6;
transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-webkit-transition: opacity 1s ease-in-out;
}
img:hover {
opacity: 1.0;
transition: opacity .55s ease-in-out;
-moz-transition: opacity .55s ease-in-out;
-webkit-transition: opacity .55s ease-in-out;
}
Since he was using the transition ease-in-out, I thought it was better to use the same transition function.
For more information, check the documentation here
Hope it helps!
http://jsfiddle.net/L7XCD/2/
Just add the transition effect to your element without the hover-tag
I am trying to make some kind of animation and I want it to happen without :hover :active or any other event. I want it to happen after 2 second page loads. In fact, I want the object come from invisible place to scene (visible area). Is there anyway of doing it ?
#scene {width:650px;height:300px;border:1px solid black;background-color:#FAFAFA;margin:0 auto;}
#sca {transition: background 2s;width:271px;height:180px;background: url(http://img521.imageshack.us/img521/7913/123hc.png) no-repeat;display:block;position:relative;right:300px; opacity:0.5;
transition: opacity 2s;
-moz-transition: opacity 2s; /* Firefox 4 */
-webkit-transition: opacity 2s; /* Safari and Chrome */
-o-transition: opacity 2s; /* Opera */
transition-delay: 2s;
-webkit-transition-delay: 2s;
}
#sca:hover {opacity:1; }
Yes it's possible, but it's not recommended. How to do it with pure CSS is shown at this site. Here is the demo provided at the site.
A more cross-compatible way of doing it would be using javascript or jQuery, specifically jQuery's ready combined with animation or more generally, effects.
Good luck!
CSS transitions work on events, and there's not any way around that. You'd have to use Javascript to do what you are looking for.
There is difference between transition (from title) and animation (from text). animation can have start without an event, but transition can't.