CSS3 Transitions

Must Read

Five tips, information and people involved in

Today is a competitive, regulated and financially stressed environment means that organizations are living in the location on the...

Setting Up a Development Environment for Windows Phone 7

You can use Microsoft® Visual Studio® development system and the Windows Phone Developer Tools to simplify application development for...

Prism Library for Windows Phone 7

Prism is a free utility library from the Microsoft® patterns & practices group. The components in this library can...

Email Marketing Tips

Be prepared. You will receive a number of emails requesting information on your company, your products, your locations, and...

In-Place Editing with contenteditable

We're always looking for ways to make it easier for people to interact with our applications. Sometimes we want...

How to Consolidate Federal Student Loans – FDLP, FFELP, Etc

The cost of higher education continues to rise. Many students are unable to afford to finish college. Because of...

Interaction invitations are important to good user experience design, and CSS has supported the :hover pseudoclass for some time so that we can do some basic interaction cues on our elements. Here’s some CSS markup that styles a link so it looks like a button:

a . b u t t o n {
p a d d i n g : lOpx;
b o r d e r : lpx s o l i d #000;
t e x t – d e c o r a t i o n : none;
a . b u t t o n : h o v e r {
b a c k g r o u n d – c o l o r : #bbb;
c o l o r : # f f f

When we place our cursor over the button, the background changes from white to gray, and the text changes from black to white. It’s an instant transition. CSS3 transitions3 let us do quite a bit more, including simple animations that were possible only with JavaScript. For
example, we can make this transition into a cross-fade by adding the following highlighted code to the style definition:

Une l a . b u t t o n{
p a d d i n g : lOpx;
b o r d e r : lpx s o l i d #000;
t e x t – d e c o r a t i o n : none;
– w e b k i t – t r a n s i t i o n – p r o p e r t y : b a c k g r o u n d – c o l o r , c o l o r ;
– w e b k i t – t r a n s i t i o n – d u r a t i o n : I s ;
– w e b k i t – t r a n s i t i o n – t i m i n g – f u n c t i o n : ease-out;

a . b u t t o n : h o v e r {
b a c k g r o u n d – c o l o r : #bbb;
c o l o r : # f f f

On line 5, we specify what properties get the transition applied. In this case, we’re changing the background and foreground colors. We specify the duration of the animation on line 6, and we specify the transition’s timing function on line 7.

Timing Functions

The transition-timing-function property describes how transitions happen over time in relation to the duration you’ve set. We specify this timing function using a cubic Bezier curve, which is defined by four control points on a graph. Each point has an X value and a Y value, from 0 to 1. The first and last control points are always set to (0.0,0.0) and (1.0,1.0), and the two middle points determine the shape of the curve.

A linear curve has its control points set to the two end points, which creates a straight line at a 45-degree angle. The four points for a linear curve are ( (0.0, 0.0), (0.0,0.0), (1.0, 1.0), (1.0, 1.0) ), and it looks like this:

Timing FunctionsA more complex curve, with points ((0.0, 0.0), (0.42,0.0), (1.0, 1.0), (1.0, 1.0)), called an ease-in curve, looks like this:

the line to curve

This time, only the second point has changed, which is what causes the bottom-left part of the line to curve.

Even more complex is the ease-in-out curve, which has a curve at the bottom and at the top, like this:

ease-in-out curve

We can specify these points right in the CSS property, or we can use some predefined ones like we did in our example.

Our choices are default, ease-in, ease-out, ease-in-out, ease-out-in, and cubic-bezier, in which you set the points of the curve yourself.

If you want the rate to be constant, you’d use linear. If you want the animation to start slow and speed up, you’d use ease-in. If you want to learn a little more about making these curves, there’s a great public domain script4 that shows you examples and helps you see the coordinates.

Play around with transitions, but keep in mind that you want your interface to be usable first and pretty second. Don’t build transitions that frustrate the user, such as things that flicker or take too long to animate. You may also want to investigate CSS3 animations,5 another method for changing CSS properties over time.


Previous articleWhere to Gn Next
Next articleWeb Workers

Latest News

Digital Marketing for Beginners

Digital marketing for starter, Let to basic learning about connecting with your audience in the right place at the...

What are 7 things poor people do that the rich don’t?

1. poor people watch TV in which people read books how many hours you spend in front of the TV and when was the...

Top 18 best small business ideas for beginners starting

A small business can be frightening and requires plenty of careful planning there are many small business ideas which can be beneficial as well...

Summer that makes you happy

We saw were already here I've been thinking about some of the things. I used to do with my husband even though he had...

4 Point to helpful tips specifically for caregivers

What you need to take a vacation. I know it sounds impossible creative and try to make it work for you almost everyone needs...

More Articles Like This