jQuery 1.4 Animation Techniques - Index of

jQuery 1.4 Animation Techniques - Index of jQuery 1.4 Animation Techniques - Index of

02.06.2013 Views

The previous screenshot shows how the hover-state is applied to one of the menu items over a short period of time, instead of instantly, as it would normally be with pure CSS, The animation proceeds from top to bottom in the previous picture. Time for action – adding the underlying markup and styling To begin with, we need to create the elements that will be used by the example and the styling to set their visual appearance. [ 23 ] Chapter 2 1. Add the following underlying markup for our navigation menu to the template file we created in Chapter 1, Introduction: Home Articles Code Demos Portfolio 2. Save the page in the jquery-animation directory as fadeIn.html. 3. We'll also need to link to a custom stylesheet for this example. Add the following code to the of the page: 4. Next we should create the stylesheet we just linked to. In a new file, add the following code: body { text-align:center; } nav { display:inline-block; font:normal 18px "Nimbus Sans L", "Helvetica Neue", "Franklin Gothic Medium", Sans-serif; border:2px solid #aaa; -moz-border- radius:7px; -webkit-border-radius:7px; border-radius:7px; } nav ul { list-style-type:none; padding:0; margin:0; } nav li { float:left; border-right:2px solid #aaa; } nav a { display:block; padding:10px 20px; position:relative; color:#333;

Fading Animations text-decoration:none; background-color:#eee; border:1px solid #fff; } nav span { display:none; width:100%; height:33px; padding-top:10px; position:absolute; top:0; left:0; background-color:#ccc; } nav .purecss a:hover { background-color:#ccc; } nav li.first a { -moz-border-radius:7px 0 0 7px; -webkit-border-top-left-radius:7px; -webkit-border-bottom-left-radius:7px; border-radius:7px 0 0 7px; } nav li.first span { -moz-border-radius:7px 0 0 7px; -webkit-border-top-left-radius:7px; -webkit-border-bottom-left-radius:7px; border-radius:7px 0 0 7px; } nav li.last { border-right:none; } nav li.last a { -moz-border-radius:0 7px 7px 0; -webkit-border-top-right-radius:7px; -webkit-border-bottom-right-radius:7px; border-radius:0 7px 7px 0; } nav li.last span { -moz-border-radius:0 7px 7px 0; -webkit-border-top-right-radius:7px; -webkit-border-bottom-right-radius:7px; border-radius:0 7px 7px 0; } 5. Save this file as fadeIn.css in the css folder within our project folder. What just happened? We use the HTML5 element as the logical container for our navigation menu. The menu itself is created from a simple unordered list, where each link is made from an anchor element within a list item. This is the simple, semantic structure that will be rendered by default. Additional enhancements will be made in our script. [ 24 ]

The previous screenshot shows how the hover-state is applied to one <strong>of</strong> the menu items<br />

over a short period <strong>of</strong> time, instead <strong>of</strong> instantly, as it would normally be with pure CSS,<br />

The animation proceeds from top to bottom in the previous picture.<br />

Time for action – adding the underlying markup and styling<br />

To begin with, we need to create the elements that will be used by the example and the<br />

styling to set their visual appearance.<br />

[ 23 ]<br />

Chapter 2<br />

1. Add the following underlying markup for our navigation menu to the template file<br />

we created in Chapter 1, Introduction:<br />

<br />

<br />

Home<br />

Articles<br />

Code<br />

Demos<br />

<br />

Portfolio<br />

<br />

<br />

<br />

2. Save the page in the jquery-animation directory as fadeIn.html.<br />

3. We'll also need to link to a custom stylesheet for this example. Add the following<br />

code to the <strong>of</strong> the page:<br />

<br />

4. Next we should create the stylesheet we just linked to. In a new file, add the<br />

following code:<br />

body { text-align:center; }<br />

nav {<br />

display:inline-block;<br />

font:normal 18px "Nimbus Sans L", "Helvetica Neue", "Franklin<br />

Gothic Medium", Sans-serif; border:2px solid #aaa; -moz-border-<br />

radius:7px; -webkit-border-radius:7px; border-radius:7px;<br />

}<br />

nav ul { list-style-type:none; padding:0; margin:0; }<br />

nav li { float:left; border-right:2px solid #aaa; }<br />

nav a {<br />

display:block; padding:10px 20px; position:relative; color:#333;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!