Animated page entry with CSS3
Create a subtle yet effective page load effect with pure CSS3.
With the continued development of modern browsers, more and more things are possible with CSS3 animations, and they grow ever more complex. Yet it is the simple things that may be most effective in enhancing user experience. Today we’ll look at one of these very simple ways of using CSS3 animations - using them to progressively fade in a page’s content.
Building on the example used by Apple recently with the release of the Beatles on iTunes, we’ll build a very simple ‘teaser’ page that fades in.
Markup
So first, the markup…
<body> <div id="content"> <p> <span class="fade-in one">Tomorrow will be just another day.</span> </p> <p> <span class="fade-in two">You will</span> <span class="fade-in three"> never</span> <span class="fade-in four"> forget.</span> </p> <p> <span class="fade-in five">See you at 10am.</span> </p> </div> </body>
CSS
And now the CSS. We’ll use two animation keyframes: one to ‘reset’ the spans so that by default they have opacity of 0 (this way browsers that don’t support the animation can still have an opacity of 1), and the other to work the fade in effect.
@keyframes reset { 0% { opacity: 0; } 100% { opacity: 0; } } @keyframes fade-in { 0% { opacity: 0; } 60% { opacity: 0; } 100% { opacity: 1; } }
We then apply these animations to the .fade-in class with separate delays for each span.
.fade-in { animation-name: reset, fade-in; animation-duration: 3s; animation-timing-function: ease-in; animation-iteration-count: 1; } .fade-in.one {animation-delay: 0, 0;} .fade-in.two {animation-delay: 0, 1s;} .fade-in.three {animation-delay: 0, 1.5s;} .fade-in.four {animation-delay: 0, 2s;} .fade-in.five {animation-delay: 0, 3s;}
And that’s all there is to it. You can build on this greatly by animating other properties, such as height, width, margins and positioning values. You may have noticed that I recently employed webkit animations to fade in images within the BMC Blog.
You can see the page in action by pressing the big blue button below - you'll need to be running Chrome of Safari to see the animations.
Enjoy the article? Tweet it!
Discussion - No comments yet…61 comments
Oooh, it's so epic!
Whoah! So was that “now saving your post” screen!
I mean, “Posting Now…” that was also epic!
Yes, I'm just posting comments to see the epic comment posting screen :D
Hello James, gonna test it out too (:
Kenneth Tsang (@jxeeno)
I've got some different owindow designs in the works… stay tuned :)
And James, while I've got your attention, any thoughts on this regarding the extended new page module?
BMC Creative | RoaringApps | @brycecammo
How would I be able to get it to load the first line in then once the rest of the lines come in, the first line fades out.
- I want to add one of the ajax loaders to it, to add a "flash" loading look to it. That will basically complete this project for me.
CEO of Icon Deposit
Take a look at me via Twitter, Dribbble, and Google +
You would need to wrap a separate span around the first line and the rest of the content, and then apply different webkit animations to each, with timing so that the first line disappears once the entire content has loaded.
As for the ajax loader, look at http://ajaxload.info - find a spinner you like and use it as you would a normal image. If you wanted to only show it while the content was loading, you could apply another webkit animation to it.
BMC Creative | RoaringApps | @brycecammo
This is what I have so far for my business site… http://www.wmdsigns.com, i have the ajax loader bar as the main loader. I have the spinner just for the jquery lightbox, and what would the timing be for it to disappear. Also should I just create fade-in.seven for the ajax loader? (I have 6 fade-in's)
CEO of Icon Deposit
Take a look at me via Twitter, Dribbble, and Google +
Looks great !
~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server | NEW: Wikiroo, backup tool (in development)
Post preview:
Close preview