Basic CSS3 Transition Format
To perform css3 transition, you have to specify the css property, easing, duration and delay (optional). Here is a example of how you can do it:
.div
{
transition: property easing duration delay;
-moz-transition: property easing duration delay; /* Firefox 4 */
-webkit-transition: property easing duration delay; /* Safari and Chrome */
-o-transition: property easing duration delay; /* Opera */
-ms-transition: property easing duration delay; /* IE9? */
}
Multiple CSS3 Transitions
To create multiple css3 transitions, you just specify the transitions separated by comma:
.div
{
color:#000;
left:0;
top:0;
transition: color ease-in 200ms, left ease-out 500mms, top linear 5s;
-moz-transition: color ease-in 200ms, left ease-out 500mms, top linear 5s;
-webkit-transition: color ease-in 200ms, left ease-out 500mms, top linear 5s;
-o-transition: color ease-in 200ms, left ease-out 500mms, top linear 5s;
-ms-transition: color ease-in 200ms, left ease-out 500mms, top linear 5s;
}
.div:hover
{
color:#FFF;
left:-100px;
top:-100px;
}
Custom CSS3 Transition Framework
I have already done couple CSS3 projects and I found that it's a great idea to have preset CSS3 transition classes with different durations in your reset stylesheet. Example of what the preset classes like:
.trans-all-300
{
transition: all ease 300ms;
-moz-transition: all ease 300ms;
-webkit-transition: all ease 300ms;
-o-transition: all ease 300ms;
-ms-transition: all ease 300ms;
}
.trans-all-500
{
transition: all ease 500ms;
-moz-transition: all ease 500ms;
-webkit-transition: all ease 500ms;
-o-transition: all ease 500ms;
-ms-transition: all ease 500ms;
}
.trans-color-250
{
transition: color ease 250ms;
-moz-transition: color ease 250ms;
-webkit-transition: color ease 250ms;
-o-transition: color ease 250ms;
-ms-transition: color ease 250ms;
}
Trigger
Usually people will apply css3 transition on :hover, :active & :focus as there are not many pseudoclass in CSS. To create a 0.5s text color transition on hover, simply do this:
.div
{
color:#333;
transition: color ease 250ms;
-webkit-transition: color ease 250ms;
-moz-transition: color ease 250ms;
-o-transition: color ease 250ms;
-ms-transition: color ease 250ms;
}
.div:hover
{
color:#FF7600;
transition: color ease 250ms;
-webkit-transition: color ease 250ms;
-moz-transition: color ease 250ms;
-o-transition: color ease 250ms;
-ms-transition: color ease 250ms;
}
More CSS3 Transition Trigger With jQuery
Other than :hover, :active and :focus, you can have more triggers by using jQuery. There are triggers such as on-load, on-scroll, on-resize and much more. Following is example of creating position-left transition on page load:
/* CSS */
#preloader
{
position:absolute;
width:100%;
height:100%;
top:300px;
left:300px;
transition: left ease 1s;
-moz-transition: left ease 1s;
-webkit-transition: left ease 1s;
-o-transition: left ease 1s;
-ms-transition: left ease 1s;
}
#preloader.active
{
left:-300px;
transition: left ease 1s;
-moz-transition: left ease 1s;
-webkit-transition: left ease 1s;
-o-transition: left ease 1s;
-ms-transition: left ease 1s;
}
/* jQuery */
$(funciton()
{
$(window).bind('load',function()
{
$('#preloader').addClass('active');
});
});
Backbone Social Media Links
{Backbone} In Facebook
Like Backbone on Facebook and Join our community!
{Backbone} Blog
{Backbone} in Twitter