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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Download from Wow! eBook <br />

[ 167 ]<br />

Chapter 6<br />

3. Save this page as puff.html. Add the following styles for the dialog box to a new<br />

file in your text editor:<br />

#confirm {<br />

display:block; width:400px; height:120px; position:absolute;<br />

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

background-image:-moz-linear-gradient(0% 5px 90deg, #eee, #666);<br />

background-image:-webkit-gradient(linear, 0% 0%, 0% 5%,<br />

from(#333), to(#eee));<br />

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

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

}<br />

#confirm img { margin:20px 20px 0 20px; float:left; }<br />

#confirm p { margin:40px 0 0 0; }<br />

#confirm button { width:68px; margin:20px 10px 0 0; float:right; }<br />

4. Save this new file as puff.css in the css directory.<br />

5. When we run the page in a browser, we should find that the dialog is initially<br />

centered in the window, and that clicking either <strong>of</strong> the elements closes it<br />

using the puff effect:<br />

The previous screenshot shows the dialog expanding while it is faded away.<br />

What just happened?<br />

The first part <strong>of</strong> our script centers the dialog in the window both vertically and horizontally.<br />

One point to note is that we cannot use margin:auto to center the dialog because it will<br />

lose these margins when the effect is applied.<br />

The second part <strong>of</strong> the script simply adds click handlers to each <strong>of</strong> the elements<br />

which apply the puff effect when they are clicked.

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

Saved successfully!

Ooh no, something went wrong!