CSS3 Transition

css3 transition 

Use CSS 3 transition to give action to elements in your website, such as change in colour, motion and more!

CSS3 Transition

The basic syntax for creating a css transition is “property”, “duration”, and “type”.

If we take the following example (transition:color 1s ease-in;) – the property we are changing is the color, over a duration of 1 second and using the ease-in method). See below some examples of how this can be implemented into your projects.

CSS3 Colour Transition Example

Mouse over this example paragraph to see it fade to a new colour using a basic CSS3 transition.

  1. CSS3 Transition (color)
  2. .my_class {
  3. transition: color .5s ease-in;
  4. -moz-transition: color .5s ease-in;
  5. -o-transition: color .5s ease-in;
  6. -webkit-transition: color .5s ease-in;
  7. }
  8. .my_class:hover {
  9. color:#066;
  10. }

This is a good technique for creating mouseover actions for links and buttons.

CSS3 Motion Transition Example

Mouse over this example paragraph to see it rotate 7degrees using a transform transition.

  1. CSS3 Transition (transform)
  2. .my_class {
  3. transition: transform .5s ease-in;
  4. -moz-transition: -moz-transform .5s ease-in;
  5. -o-transition: -o-transform .5s ease-in;
  6. -webkit-transition: -webkit-transform .5s ease-in;
  7. }
  8. .my_class:hover {
  9. transform: rotate(7deg);
  10. -moz-transform: rotate(7deg);
  11. -o-transform: rotate(7deg);
  12. -webkit-transform: rotate(7deg);
  13. }

This can be used to create a more interactive website, such as menu items or image gallery.

css transition

The Zen Elements CSS3 Series

Thank you for reading!
@zenelements // alex

Like this article?

Subscribe to our rss, follow our tweets or please help us spread the work & share this with your friends!

Thank you for all your support; have a cookie!

5 Comments on “CSS3 Transition”

  1. Dean 26.05.2011 at 1:29 pm

    Thank you for this quite reference. However, it seems that there is an error in the motion transition example. The code should really be,

    .my_class {
    transition: -webkit-transform .5s ease-in;
    -moz-transition: -moz-transform .5s ease-in;
    -o-transition: -o-transform .5s ease-in;
    -webkit-transition: -webkit-transform .5s ease-in;
    }

  2. Zen Elements 26.05.2011 at 2:40 pm

    Thank you, Dean! You’re quite right and this must have been a result of a long day and too little caffeine.

  3. Andy 22.07.2011 at 10:58 am

    Thank you Zen Elements for simple examples of CSS 3 uses!

    Great little resource, we will be back for more!

    We’ve added you to a post on our blog.

    All the best,

    Andy
    Big Eye Deers, Cardiff

  4. ?? ??? 13.08.2011 at 6:17 pm

    Thanks for good lessons about CSS3.

  5. Danny 12.12.2011 at 4:21 pm

    Thanks for this excellent summary.

 

Leave a Reply

(required; who are you?)

(required; we'll keep it safe!)

(optional; promote your site!)