transition - HTML CSS CSS Property

HTML CSS examples for CSS Property:transition

Description

The transition CSS property defines the transition between two states of an element.

It is a shorthand property for transition-property, transition-duration, transition-timing-function and transition-delay.

The following table summarizes the transition Property.

Item Value
Default value: all 0 ease 0; See individual properties
Applies to:All elements, ::before and ::after pseudo-elements
Inherited: No
Animatable: No.

Syntax

The syntax of the property is as follows:


transition:     transition1 [, transition2, ... transitionN] | initial | inherit 

where transition is: [ transition-property | transition-duration | transition-timing-function | transition-delay ]

Property Values

The following table describes the values of this property.

Value Description
transition-propertynames of the CSS properties in a transition.
transition-durationseconds or milliseconds to complete a transition animation.
transition-timing-function how the intermediate values of transition will be calculated.
transition-delay Set when the transition will start.
initialSets this property to its default value.
inherittake the value of its parent element transition property.

The example below shows the transition property.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html lang="en">
 <head>
  <title>Example of CSS3 transition Property</title>
  <style type="text/css">
  button {<!-- w w w.j  a  v a2  s. com-->
    font-size: 16px;
        font-weight: bold;
        padding: 10px 20px;
    background: #fd7c2a;
    border: 3px solid #dc5801;
    -webkit-transition-property: background 2s, border 2s; /* For Safari 3.0+ */
    transition: background 2s, border 2s; /* Standard syntax */
  }
  button:hover {
    background: #3cc16e;
    border-color: #257644;
  }
</style>
 </head>
 <body>
  <button type="button">Place mouse on me</button>
 </body>
</html>

Related Tutorials