Often happens that customers require to implement transitions between pages, nice animations, etc. also in a mobile web sites.
This kind of effects usually belong to Flash web sites but unfortunately on iOS devices there is still no support for Flash. Thanks to “Stevie” in fact the web on the mobile is growing up without the Flash Player but the request the customers have are always the same: nice transitions, cool effects, etc.
The result is that we have to use technologies that are pretty new and without a strong background like Flash to satisfy customer’s request.
Anyway, let’s see hot to create a transition effect on an iOS device with CSS and the webkit transitions.
It’s pretty easy to create a page transition effect using the webkit transitions in a CSS file or declaration.
As of June 2011, Firefox 5 includes CSS Animation support. CSS animation is also available as a module in the nightly builds of WebKit as well as Google Chrome, Safari 4 and 5 and Safari for iPhone, Android 2.x and 3.x, the RIM OS6 web browser, with the -webkit- prefix.
The syntax to define a transition is pretty sample, it’s enough to use the @-webkit-keyframes directive followed by the name of the transition
In the curly braces that follow the name of the transition it’s possible to define which properties have to be changed at a specific time
font-size: 10px;
}
50%{
font-size: 20px;
}
100%{
font-size: 30px;
}
If an animation has the same starting and ending properties, you can comma separate the percentage values and define the properties
font-size: 30px;
}
If you want to create infinite animation you can do it easily combining transitions and transformation.
In this case usually the from and to keyword are used but actually have the same meaning of 0% and 100%.
In order to create a fade in page effect you can just declare in a CSS file two animations
0% {
opacity: 0;
}
100% {
opacity: 0;
}
}
@-webkit-keyframes fadein {
0% {
opacity: 0;
}
60% {
opacity: 0;
font-size: 25px;
}
100% {
opacity: 1;
font-size: 45px;
}
}
The first one is the one needed to make the page blank when loaded.
After you define the animations it’s enough to create a new CSS class specifying which animations to use, the duration, the timing function and the iteration count
-webkit-animation-name: reset, fadein;
-webkit-animation-duration: 2s;
-webkit-animation-timing-function: ease-in;
-webkit-animation-iteration-count: 1;
}
If you want that the elements in your page fade in with a specific amount of delay you can add the following lines to your CSS
.fadein.second {-webkit-animation-delay: 0, 1s;}
.fadein.third {-webkit-animation-delay: 0, 1.5s;}
In the HTML page you have to import your CSS and use the sub classes already defined in order to see your animations working properly
The content you want to show <b>first</b>...
</div>
<div>
The content you want to show <b>second</b>...
</div>
<div>
The content you want to show <b>third</b>...
</div>
The sample animation defined above changes also the font size, actually I did it just in order to show that you can combine more than one properties and create pretty nice effect to show the elements of your pages.
If you enjoyed this article, you might also like...
Post comment
About MobileRevamp
The aim of this community is to share as much as possible information related to the mobile development using all the social networks and the new capabilities of the NET to make easier find updated contents and to create a deep feeling of connection between developers.
Updates
Archives
Recent Comments
- Giorgio Natili on Mobile Flash player 10.1 OR AIR 2.6 on Android?
- Patric on Mobile Flash player 10.1 OR AIR 2.6 on Android?
- AIR4Android on How to build your first AIR4Android application using FDT and Eclipse
- Tonsula on How to build your first AIR4Android application using FDT and Eclipse
- jbozabalian on Cross plarform mobile development
Adobe Mobile UGs
- Adobe Groups
- Australia MaDUG
- Boston MaDUG
- Brazil MaDUG
- Copenhagen MaDUG
- Dallas MaDUG
- India MaDUG
- Polish MaDUG
- Spain MaDUG
- UK MaDUG
Authors













