New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

Start learning with our library of video tutorials taught by experts. Get started

CSS: Transitions and Transforms
Illustration by

Growing page elements


From:

CSS: Transitions and Transforms

with Joseph Lowery

Video: Growing page elements

For the most part, when folks talk about scaling, they are thinking of making things larger, and most of what gets scaled up are images. In this movie we are going to follow that well-beaten path, as I show you how to resize a series of images on hover. We will even toss in a box shadow for that extra 3D kick. Let's take a look at a before-and- after scenario, so you can get an idea of what we're trying to do. I have open in the browser here, the about.htm file from the Chapter 2/02_03/ about folder of the exercise files.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
please wait ...
CSS: Transitions and Transforms
2h 25m Intermediate Jul 11, 2012

Viewers: in countries Watching now:

With robust and ever-increasing browser support, it is now possible to take advantage of expressive CSS3 capabilities across modern browsers. In this course, Joseph Lowery explores the possibilities of the new coding options, which animate well over 50 different properties automatically or interactively, and how they open the door to enhanced user experiences. This course covers the range from simple to complex transitions, including 2D and 3D transforms, and illustrates how transitions are expedited in various web authoring tools, as well as Dreamweaver. The course also contains a start-to-finish interactive slideshow project that allows you to practice and see the transitions and transforms immediately in action.

Topics include:
  • Understanding transition basics
  • Working with 2D and 3D transforms
  • Animating color changes
  • Fading objects
  • Changing the size of page elements and fonts
  • Transitioning multiple properties at the same time
  • Understanding keyframes and animations
  • Working in the z-index
  • Adding JavaScript interactivity
  • Crafting transitions in Dreamweaver
Subjects:
Web Web Design Web Development
Software:
CSS
Author:
Joseph Lowery

Growing page elements

For the most part, when folks talk about scaling, they are thinking of making things larger, and most of what gets scaled up are images. In this movie we are going to follow that well-beaten path, as I show you how to resize a series of images on hover. We will even toss in a box shadow for that extra 3D kick. Let's take a look at a before-and- after scenario, so you can get an idea of what we're trying to do. I have open in the browser here, the about.htm file from the Chapter 2/02_03/ about folder of the exercise files.

Right now, the four images are static, and if I move my mouse over them, nothing happens. That's fine for a nice fallback position. But let's make it a little snappier for more modern browsers, and let's switch to a final version of this. And when I hover over any of the images, they scale up 50% larger than what they were before. And when I move my mouse off the image, it scales back down to normal and the next image scales up, Hours of Fun. In this situation my HTML is just fine; all I need to work with is a CSS file, which is the main.css file.

So let's switch over to the code editor, and here I have main.css from the Chapter 2/02_03_css folder. The first thing I am going to need to do is to set up the Transitions. Instead of specifying a particular property this time, however, I am going to use a keyword, all, which will allow even the box shadow property to transition in. So I am going to scroll down to the bottom, where I have the rules I am going to need to modify, Enter.

And the first one I need to change is #theArt img tag. So again I will start out with the webkit transition. And as I said, instead of using a specific property, we will use the keyword all, and we want this to happen pretty quickly, so I am going to just put in a half second duration, .5s. And let's use the ease timing function. Okay, so I will copy that and then paste it three more times, and then adjust my vendor prefixes, replacing -webkit with -moz, the first time.

And then the second time on the third line we will replace -webkit with -o. And finally, we will get rid of it altogether. So now, let's create a rule to handle the hover state with our transforms. We will use the same basic selector ID #theArt, image tag, and to that we will add hover state. Let's start by entering in the scale function, and the syntax for that is -webkit-transform:scale.

And because I am going to scale it up in both directions at the same value, I can enter in just a single value, 1.5. Now we will increase the size of the image by 50%. So let me finish it off with a semicolon. And as we did with the transitions, we can just copy this and paste it. This time I'm going to paste it one additional time so that we can add in the prefix for Internet Explorer, which is -ms for Microsoft. So first, let's replace -webkit in the second line here with -moz, for Mozilla.

And on the third entry, instead of replacing -webkit with -o for Opera, let's use -ms for Microsoft. Now the reason we're doing it here in the transform and not in the transition is because Internet Explorer 9 actually supports transform with a vendor prefix of -ms, although it does not support transition. Let's move on and replace -webkit in the fourth line with -o, and as we have done before, let's go with our generic CSS3 property of transform by removing -webkit entirely from the final entry.

One more series of properties that we want to add to this rule, and that's the box shadow property. Again, there are vendor prefixes for this property, although not quite as many. We only to enter one for -webkit, one for Mozilla, and then the generic box shadow itself. Okay, so let's do -webkit-box-shadow, and we will offset the shadow in both X and Y directions by 3 pixels. So 3px, 3px, spread it out to 5 pixels, 5px, and give black in the color in a hexadecimal format.

So #000, close it off with a semicolon. Again, we can copy this to save a little typing and paste it in twice. As I mentioned we only need the Mozilla prefix as the second one, and the third entry is, of course, box shadow by itself. All right, let's save our file and then head back to Firefox. Let's go to our previously before figure now. And that I'll reload the page and hover over each of the images, and there is our new effect added, smooth as silk.

And by box shadow looks pretty good as well. Now before we leave this section, I want to tell you about a glitch I discovered when I was developing this particular movie. When I viewed the page in a webkit browser, either Safari or Chrome, I noticed a jump appearing at either end of the scaling. First, when it gets large and then again, when it returned to its original size. Now we are not seeing it now because the browsers have been updated, but this effect definitely appeared in earlier versions of the webkit browser.

So I was forced to find a solution for that. The solution is applying the webkit backface-visibility property. As discussed in the chapter on 3D Transforms, this property toggles the rendering of back size of 2D elements. Luckily, it also has the desired effect in the 2D environment. So, in order to fix this issue for backwards compatible browsers, we will need to add one more bit of code. Here in my hover state, I will press Return to make space for one more entry and enter in webkit-backface-visibility: hidden.

And again, for earlier versions of the browser, which you may or may not have installed, you don't need to do other vendor-specific entries for it. Okay, our scaling project is complete, but before we go, let me leave you with two thoughts. First, for optimum image results, you want to create your images in their final scaled up size and then insert them with reduced width and height for the smaller thumbnails. And second, keep in mind that scaling isn't just for images; you can also apply to page sections, like the sides to give them emphasis, or even Submit buttons, to encourage people to click.

There are currently no FAQs about CSS: Transitions and Transforms.

 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

join now Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed CSS: Transitions and Transforms.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.