PSD-HTML. These Pixel perfect HTML pages will be tested on Chrome, Firefox, IE, Safari on OS X and Windows Imajine will help you create your own fan page in facebook with an eye appealing graphic banner for its welcome page Custom CMS theme building weboranje.com - showcase of inspirational web 2.0 websites
Animation in CSS3

In CSS, we can try out simple animation like moving an object on either x-axis, y-axis or both by using the property ' -webkit-transition'.You can hover over the car in the following output, to view the animation in Google chrome browsers.

 

Steps followed for the above animation are given below.

1. Give a background div for the image. Here it was taken as the road.

The code for which is given :

#road
{ position: relative;
height:180px;
background: url(images/road.jpg);
width:600px;
}

The height and width parameters of the above div would depend on the image size.

2. Assign a div for the placement of image

#car {
position: absolute;
bottom:30px;
left: 20px;
}

The position values are assigned as absolute. We can vary the left and bottom margins in accordance to the background.

3. Assign a style to the image

.car_img
{
-webkit-transition: 2s ease-in-out;
}

The above code will cause the animation to last for 2 seconds

4 Give hover effect to the image

.car_img:hover
{
-webkit-transform: translate(400px,0px);
}


In the above code we have animated the car using '-webkit-transform: translate(x,y)' property. Here we assigned only the x-value as we wanted our car to move horizontally .For any object to move on both axes we can assign value to y-axis too.

The HTML code for the above style was given as:

<div id="road">
<div id="car">
<a href="#" target="_blank"><img src="images/car.png" border="0" class="car_img" /></a>
</div>
</div>

Hope you enjoyed the tutorial and will try out different animations using CSS.

Tags: Animation in CSS3, style for animation, style for motion, moving objects in CSS3, moving objects in x and y axis, -webkit-transition, webkit transition tutorial.

 

Bookmark and Share
HI, AM JAY, AND I IMAJINE
I am a freelance web designer and web application developer with over 7 years of result oriented experience. I am accustomed to working in a dynamic and goal oriented client environment. My strengths include the ability to visualize, personalize and create a truly unique and enthralling web presence. My passion apart from web design, logo design, Flash animation / actionscripting, CMS Customization, print and web development includes photography, game programming, tutorial development (includes Adobe Flash, Adobe Fireworks and Adobe Photoshop) and blogging.
Read more about me...
CONTACT US
Name :  
Email Address :  
 
Comments :
 
jayanthi.varma@imajine.in  |  © 2008 - 2012 Imajine.