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

2. Save the new page as marquee.html. [ 221 ] Chapter 8 3. We can also add some basic CSS at this point to layout the example in an acceptable, generic manner. In a new file in your text editor, add the following code: #outer { width:960px; margin:auto; color:#3c3c3c; font:normal 17px "Palatino Linotype", "Book Antiqua", Palatino, serif; } header { display:block; padding:0 20px 0; margin-bottom:40px; border:3px solid #d3d1d1; background-color:#e5e5e5; } hgroup { float:left; } h1, h2 { margin-bottom:10px; } nav { display:block; width:100%; height:40px; clear:both; text-align:right; } article { width:700px; height:900px; border:3px solid #d3d1d1; background-color:#e5e5e5; float:left; } article h1, article p { margin:20px; } p , nav{ font:normal 17px "Nimbus Sans L", "Helvetica Neue", "Franklin Gothic Medium", Sans-serif; } p { margin-top:0; } aside { width:220px; height:900px; border:3px solid #d3d1d1; background-color:#e5e5e5; float:right; } aside div { padding:0 20px 20px; } 4. Save this file as marquee.css in the css directory. Link to this stylesheet from the of the page we just created.

Other Popular Animations What just happened? The underlying HTML represents a typical blog. We've added a series of elements for two reasons, primarily so that we have somewhere to insert the marquee, but also so that we can see why this approach can be necessary. Having the latest posts scrolling across the page near the top of the site ensures that this content is seen straight away, and the fact that it's animated also helps to draw the visitor's attention to it. The CSS used so far is purely to layout the example elements in a precise and mildly aesthetic way, giving us a generic layout and a light skinning. We'll add some more CSS a little later in the example for our dynamically created marquee. At this point, the page should appear like this: Remember, all of the elements in the previous screenshot are there for the marquee to be inserted between. They are not specifically required, and are there for this example. Time for action – retrieving and processing the post list Now we're ready to retrieve the list of latest posts and process them, making them ready to be displayed as items in the marquee. In order to access this data across the Internet from another domain, we need to use JSONP, which stands for JSON with Padding, and involves dynamically creating and injecting a element to the page, although jQuery actually handles this aspect of it for us. [ 222 ]

2. Save the new page as marquee.html.<br />

[ 221 ]<br />

Chapter 8<br />

3. We can also add some basic CSS at this point to layout the example in an acceptable,<br />

generic manner. In a new file in your text editor, add the following code:<br />

#outer {<br />

width:960px; margin:auto; color:#3c3c3c;<br />

font:normal 17px "Palatino Linotype", "Book Antiqua",<br />

Palatino, serif;<br />

}<br />

header {<br />

display:block; padding:0 20px 0; margin-bottom:40px;<br />

border:3px solid #d3d1d1; background-color:#e5e5e5;<br />

}<br />

hgroup { float:left; }<br />

h1, h2 { margin-bottom:10px; }<br />

nav {<br />

display:block; width:100%; height:40px; clear:both;<br />

text-align:right;<br />

}<br />

article {<br />

width:700px; height:900px; border:3px solid #d3d1d1;<br />

background-color:#e5e5e5; float:left;<br />

}<br />

article h1, article p { margin:20px; }<br />

p , nav{<br />

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

"Franklin Gothic Medium", Sans-serif;<br />

}<br />

p { margin-top:0; }<br />

aside {<br />

width:220px; height:900px; border:3px solid #d3d1d1;<br />

background-color:#e5e5e5; float:right;<br />

}<br />

aside div { padding:0 20px 20px; }<br />

4. Save this file as marquee.css in the css directory. Link to this stylesheet from the<br />

<strong>of</strong> the page we just created.

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

Saved successfully!

Ooh no, something went wrong!