02.06.2013 Views

jQuery 1.4 Animation Techniques - Index of

jQuery 1.4 Animation Techniques - Index of

jQuery 1.4 Animation Techniques - Index of

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

[ 209 ]<br />

Chapter 8<br />

}<br />

.slider #scroller { position:absolute; left:0; top:0; }<br />

.slider #scroller img {<br />

display:block; width:150px; height:150px; margin:50px 0 0 50px;<br />

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

}<br />

.slider #scroller img:first-child { margin-left:0; }<br />

#message {<br />

width:100%; height:30px; padding-top:10px; margin:0;<br />

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

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

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

border-radius:0 0 8px 8px; position:absolute; bottom:0;<br />

left:0;<br />

background-color:#000; color:#fff; text-align:center;<br />

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

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

}<br />

3. Save this in the css folder as proximity.css and don't forget to link to it from the<br />

<strong>of</strong> the HTML page.<br />

What just happened?<br />

Keeping the HTML as simple and as light as possible, we simply add the images that we want<br />

to show to a container element. Any extra elements that we need can be added dynamically<br />

in the nature <strong>of</strong> progressive enhancement.<br />

There are two sections in the CSS file. The first section is a collection <strong>of</strong> base styles which<br />

are used if the page is loaded by a visitor that has JavaScript disabled. This ensures that<br />

all <strong>of</strong> the images are visible and therefore accessible—none <strong>of</strong> them are hidden or<br />

otherwise obscured.<br />

The second section changes the appearance <strong>of</strong> the container element and adds styling to<br />

elements or classes that are added dynamically, transforming the appearance <strong>of</strong> the slider,<br />

provided JavaScript is enabled.<br />

We set the height and width <strong>of</strong> the container so that only three images are visible at any<br />

one time and set its overflow style property to hidden so that all <strong>of</strong> the other images are<br />

hidden, ready to be scrolled into view.<br />

We also add positioning for an element with an id <strong>of</strong> scroller. This element doesn't yet<br />

exist and will be added by the script, which we'll look at shortly. This element will also need<br />

a width, but we can assign this dynamically based on the number <strong>of</strong> images in the container.

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

Saved successfully!

Ooh no, something went wrong!