I want a CSS3 linear transition for a "list-style-image". It will be for Firefox, so it will have "-moz-".
-moz-transition: list-style-image 0.2s linear;
The above code does not work. Is it even possible? Thanks in advance.
No. Transitions generally only work on things where the intermediate steps can be calculated in a predictable way: colors or numbers (in px, em, generally). Images or binary style types (like display none/block) are either one value or the other, and have no intermediate values to use in transition.
Related
Tailwind offers multiple utilities for controlling which CSS properties transition, among these properties there are transition and transition-all.
I went and checked the CSS properties for both classes and here they are in the same order.
transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 150ms;
transition-property: all;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 150ms;
What is the difference between both classes and which one should I use for general transitions?
To understand the difference you need to understand an important thing about animatable properties. Some of them trigger layout changes and some of them don't.
A property that trigger a layout change will have an impact on the performance so it's recommended to avoid them as much as possible
A property that doesn't trigger a layout change will have less impact on the performance and it's recommended to animate them.
The transition class of tailwind is grouping the second set of properties (the ones that don't trigger layout change) while transition-all group all of them.
It's better to rely on transition to have good performance and you should avoid as much as possible transition-all but if you are obliged to animate all the properties then use it.
Here is a good reference to help you understand what I am talking about: https://csstriggers.com/
If you check for color you can read:
Changing color does not trigger any geometry changes, which is good.
As a side note, transform is the best when it comes to performance. It doesn't trigger layout change and doesn't trigger painting:
Changing transform does not trigger any geometry changes or painting, which is very good. This means that the operation can likely be carried out by the compositor thread with the help of the GPU.
As you mentioned, Tailwind's transition class defines transitions for a limited set of CSS properties: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter.
When using transition-all all properties that can transition will - this includes all animatable CSS properties (properties in transition and much more).
Using one or the other will depend on which properties you want to animate, if they're all covered by transition then there's no need to use transition-all.
I think If you need all properties its better to use transition-all
but if you want to be specific Use the transition-{properties} utilities to specify which properties should transition when they change.
e.g. transition-color going to be
transition-property: background-color, border-color, color, fill, stroke; as tailwind doc
I would like to add a transition on an element when I am changing its position (from static to fixed).
I tried doing a transition: transition: position 2s linear; but it actually doesn't do anything. Is there anything else I could try ?
Thanks
You're using the declaration properly, however you can only transition numeric values - this is because transition will calculate inbetween steps for the two values you're transitioning between, and while 0% and 100% have steps inbetween, there is no valuefor three-quarters-fixed-one-quarter-static.
The working draft for the transition shorthand has a few pointers on what can reasonably be animated.
In other words, you won't be able to animate this with transition, so the only possible way is likely through JS at this point. With the code you provided, that is impossible to say, though.
I found the following short definition of CSS transition commands, but I don't know what those stand for:
-webkit-transition: all 0.35s ease-in-out 0s;
What does the all stand for?
Why 0s ?
all means that all animatable properties are going to be animated; it's the default, so it can be omitted; of course, you are going to see a transition only for those properties that actually change value between initial and final state;
0s is the transition delay; can be omitted if it's 0s (there may be
issues in some browsers with writing just 0 instead of 0s)
So that code is actually equivalent to:
transition: .35s ease-in-out;
Also, the line you've written uses the -webkit- prefix which means it's only going to work only in WebKit browsers. However, all current versions of desktop browsers that support transitions support them unprefixed.
There are some great articles detailing the use of transition -
http://css-tricks.com/almanac/properties/t/transition/
https://developer.mozilla.org/en-US/docs/Web/CSS/transition
'All' specifies the properties to transition.
The final time parameter is a delay argument. '0s' means, as you'd expect, no delay.
If I wanted to transition just the background colour, and delay by 4 seconds, I would write:
transition: background-color 0.35s ease-in-out 4s;
transition: <property> <duration> <easing> <delay>;
Universal property transition is shorthand for 4 individual properties: transition-property, transition-duration,transition-delay, and transition-timing-function.
First 2 properties are required even though a default value for transition-property is all which defines that all properties that can transition will transition. The transition-timing-function property is defined by predefined functions.
Duration and delay properties are defined with seconds or milliseconds, just keep in mind that first time defined is always duration.
Source: https://kolosek.com/css-transition/
I have a Ul tag on hover of it, I display a div using css.
Now i want that div tag will 1st fadein or any other effect like animate etc.
I know it can be done easily by using jQuery, but want to know can i achieve this using Html5,css3,css
Here JsFiddle
Fading in http://jsfiddle.net/thebabydino/Cedue/7/
There was never anything like -webkit-opacity or -moz-opacity
If you want to transition the opacity, then either write
transition: opacity 1s
or
transition: 1s
From what I can tell, removing the display: none; and display: block; lines from your code enables animation:
http://jsfiddle.net/Cedue/31/
(That is a copy of your original fiddle with only the display: lines removed.) However, this raises the issue that you can access, highlight, and even hover the text when it's hidden; if you do not wish to have that behavior you might wish to look into another means of hiding it until the correct area is hovered, such as shifting it with margins.
As Ana has mentioned, as well, if you wish to animate the entire fade you should use opacity as your transition parameter (e.g.: transition: opacity 1s ease;, with the additional lines for separate browser support). If you use background as the transition property as you do in your example, only the background fades and the text appears instantly.
EDIT: due to my own curiosity I tested this under Chrome and Firefox, each for both Windows and Mac, and can confirm that removing the display lines caused the animation to work on all of them.
Check this site, it uses css and javascript.
Pure CSS implementation here.
You should look into CSS3 transitions http://www.alistapart.com/articles/understanding-css3-transitions/
I'm using WebKit transition to animate certain CSS changes.
For example, say I've got a red box that I want to change to green when someone hovers. I use this:
-webkit-transition-duration: 200ms;
-webkit-transition-property: background;
-webkit-transition-timing-function: ease;
That works great. But now, say I want it to also slide downwards a bit. I use this:
-webkit-transition-property: background, margin;
That also works okay, but I want the box to slide down quickly (say 50ms). I can't change -duration because that would make the color animate fast.
How can I assign different durations to different properties in CSS animations?
I'm fine with using keyframe animations if necessary, but I haven't seen a way that they can help me.
jsfiddle for reference
Duratons can be comma-separated, corresponding to the transitioned properties, ie:
-webkit-transition-duration: 50ms, 200ms;
-webkit-transition-property: margin, background;
http://jsfiddle.net/bQ8d7/1/