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 ]

Fading <strong>Animation</strong>s<br />

text-decoration:none; background-color:#eee;<br />

border:1px solid #fff;<br />

}<br />

nav span {<br />

display:none; width:100%; height:33px; padding-top:10px;<br />

position:absolute; top:0; left:0; background-color:#ccc;<br />

}<br />

nav .purecss a:hover { background-color:#ccc; }<br />

nav li.first a {<br />

-moz-border-radius:7px 0 0 7px;<br />

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

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

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

}<br />

nav li.first span {<br />

-moz-border-radius:7px 0 0 7px;<br />

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

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

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

}<br />

nav li.last { border-right:none; }<br />

nav li.last a {<br />

-moz-border-radius:0 7px 7px 0;<br />

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

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

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

}<br />

nav li.last span {<br />

-moz-border-radius:0 7px 7px 0;<br />

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

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

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

}<br />

5. Save this file as fadeIn.css in the css folder within our project folder.<br />

What just happened?<br />

We use the HTML5 element as the logical container for our navigation menu. The<br />

menu itself is created from a simple unordered list, where each link is made from an anchor<br />

element within a list item. This is the simple, semantic structure that will be rendered by<br />

default. Additional enhancements will be made in our script.<br />

[ 24 ]

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

Saved successfully!

Ooh no, something went wrong!