Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to best set a CSS3 transition to none?

How would I make it so a CSS transition doesn't work inside a media-query, or in any other case? For example:

@media (min-width: 200px) {     element {         transition: width 1s;     }    }  @media (min-width: 600px) {     element {         transition: none; // SET TO NO TRANSITION     }    } 
like image 233
shrewdbeans Avatar asked Aug 07 '12 14:08

shrewdbeans


People also ask

How do I change a transition to none in CSS?

Even better than setting transition-property to none is setting transition-duration to 0s. This is the cross-browser code: -webkit-transition-duration: 0s; -moz-transition-duration: 0s; -o-transition-duration: 0s; transition-duration: 0s; Why is this better?

What is ease in transition CSS?

ease - specifies a transition effect with a slow start, then fast, then end slowly (this is default) linear - specifies a transition effect with the same speed from start to end.

How do you create transition effects using css3?

To make the transition occur, you must specify at least two things — the name of the CSS property to which you want to apply the transition effect using the transition-property CSS property, and the duration of the transition effect (greater than 0) using the transition-duration CSS property.

How do you use transitions in CSS?

CSS Transitions. CSS transitions allows you to change property values smoothly, over a given duration. Mouse over the element below to see a CSS transition effect: ... ease-in-out - specifies a transition effect with a slow start and end; cubic-bezier(n,n,n,n) - lets you define your own values in a cubic-bezier function;

How many transitions are there on the CSS display property 0?

Linked 1732 Transitions on the CSS display property 0 how to add class with animation? Related 1295 What is the difference between visibility:hidden and display:none? 360

What is a transition property in JavaScript?

The transition property is specified as one or more single-property transitions, separated by commas. Each single-property transition describes the transition that should be applied to a single property (or the special values all and none ). It includes: zero or one value representing the property to which the transition should apply.

What is the default duration of transition effect in HTML?

Note: If the duration part is not specified, the transition will have no effect, because the default value is 0. The following example shows a 100px * 100px red <div> element. The <div> element has also specified a transition effect for the width property, with a duration of 2 seconds:


2 Answers

You can set the transition-property to none. This way, no transition effect will be applied.

Like this:

-webkit-transition-property: none; -moz-transition-property: none; -o-transition-property: none; transition-property: none; 
like image 79
Christofer Vilander Avatar answered Sep 18 '22 00:09

Christofer Vilander


Even better than setting transition-property to none is setting transition-duration to 0s.

This is the cross-browser code:

-webkit-transition-duration: 0s; -moz-transition-duration: 0s; -o-transition-duration: 0s; transition-duration: 0s; 

Why is this better? Because, by default, standards-compliant browsers (such as Firefox) set transition-property to all for each element. They also set transition-duration to 0s. Thus, by setting transition-duration to 0s, you are most closely matching how the browser defines an element without a transition.

Setting the transition-duration to the default 0s renders the transition-property irrelevant.

like image 36
RockPaperLz- Mask it or Casket Avatar answered Sep 17 '22 00:09

RockPaperLz- Mask it or Casket