With jQuery we can create impressive screen effects using animations. In this post I'm going to show you how to create a simple screen effect with animations, ideal for an introduction to your web site. First of all, we need a basic markup structure to start with. Some of these elements have been inserted in the markup just for the sake of the example. You can obviously insert them with jQuery:
<div id="center-screen"> <h1>Screen Title</h1> </div> <div id="screen"> <div id="left-screen"></div> <div id="right-screen"></div> </div>
A couple of CSS rules to display them as we want:
html, body { margin: 0; padding: 0; font: 100% Arial, sans-serif; overflow: hidden; } #screen { width: 100%; height: 200px; position: absolute; top: 50%; margin-top: -100px; z-index: 0; } #left-screen { width: 0px; height: 100%; background: #d40; position: absolute; top: 0; left: 0; z-index: 1; } #right-screen { width: 0px; height: 100%; background: #d40; position: absolute; top: 0; right: 0; z-index: 1; } #center-screen { width: 750px; height: 200px; position: absolute; display: none; top: 50%; left: 50%; margin: -100px 0 0 -375px; color: #fff; background: #f50; text-align: center; z-index: 2; line-height: 200px; } #center-screen h1 { font-size: 100px; font-weight: normal; text-transform: uppercase; width: 100%; height: 100%; margin: 0; } #center-screen h1.title { width: 100%; height: 200px; position: absolute; top: 50%; left: 0; margin: -100px 0 0 0; text-align: center; z-index: 3; line-height: 200px; font-size: 100px; }
Now jQuery:
$(document).ready(function() { $('#left-screen, #right-screen').animate({ width: '51%' }, 5000, function() { $('#center-screen').fadeIn(2000).animate({ width: '100%', height: '100%', top: 0, left: 0, margin: 0, fontSize: '200px' }, 1000, function() { $(this).find('h1').addClass('title').end().animate({ opacity: '0.5', fontSize: '100px' }, 1000); }); }); });
I've tested this code in Chrome, Firefox, Safari and Opera, that is, in all standard-compliant browsers. Please let me know how IE renders it. You can see the demo below.
nice effect master...\m/