Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
We will begin by talking about one of the new features in Dreamweaver CS6 and frankly, it's one of my favorite new features, which is support for CSS3 Transitions. So I have the index.html file open here from the 11_01. And essentially let me show you what I want to do here. I am going to just preview this in one of my browsers. All right, what I would like to do is hover over these particular info boxes and have them expand to show their contents because there is more to these than you can see right now. If we go into Design View for example, you can see that each of these has some text.
So I have created a class and if I click inside this one you can see it, it is the condense class. So any of these sections that have a class condense applied to it I want to go ahead and sort of expand those and do that particular property animation. Well, now I'm certainly free to go into my CSS Styles and hand code that myself. I could even go over the CSS Styles Panel and it has support for many of the transition properties and if I know the syntax of it and how to do it I could go ahead and construct it through the CSS Styles Panel. But what if I don't know these things or what if I just wanted to do it really quickly.
All right, so what I am going to do is I am going to go up to the Menu and go to Window and I am going to choose CSS Transitions, it's about midway down. Now that brings up my CSS Transitions Panel, and of course you can dock that to anyone of your workspaces if you want to. And what I am going to do is I am just going to click the Plus symbol to create a brand-new transition. Now when I do that, I get the New Transition dialog box, now I am free to go in and type in any rule that I want to target. So if you're in the middle of creating your CSS file and you haven't created the selector yet that you want to target you could go ahead and create it right now if you wanted to.
In this case however, the selector that I want to target or the element that I want to target, that selector is already written. So I am going to grab that pulldown menu and I am going to scroll all the way down, they are more or less in alphabetical order, and I want to find this section condense, so section.condense. And the next thing I have to choose is when I want this to animate, when do I want these properties to animate. Notice that we have several choices here, we can do active, checked, disabled, enabled so you can do this a lot with forms actually, focus, hover, indeterminate, that's a nice one and target.
Now what we are going to do is we are going to do a hover. So when somebody hovers over these. Now if I am going to transition multiple properties I then face with the choice of do I use the same transition, meaning the same speed, duration, easing that sort of thing for all the properties or do I want to do them separately. What if we wanted for example, these to extend in terms of their height and then after they were done animating out change the background color? Well, to do that we would have to use a different transition for all properties. So just to sort of demonstrate we are only going to do one property but just to demonstrate the difference in the way the interface looks only, I am going to use a different transition for each property.
So it changes the interface a little bit, but not in a very large way. So what I am going to do is I need to go down and find the property that I want to change. Let me tell you, you can have the property that we've already set on the section.condense, because there is a two-step process here. Well in section.condense I have a Height value applied to it that's making it a specific height. Now I am actually not using the height property, I am using max-height, so a maximum height. And currently the maximum height of each of those is 308 pixels. So it's sort of saying, even though you have a lot more content in that I am not going to allow you go past 308 pixels.
I am then also telling it that any content that doesn't fit inside there I have an overflow property of hidden and that's going to hide the content so that you can't see it if it doesn't fit within that particular height. Now why am I using max-height instead of height? Well, that has everything to do with some rendering errors or I guess it's actually a problem in the specification to be honest with you, is the specification doesn't support a value for height of auto. So unless each one of these is going to be exactly the same height which it isn't, then I need to use a property like maximum height.
Okay, that's probably way more information than you wanted to know. So what I am going to do here is I am going to click the Plus symbol to go ahead and select one of these properties and of course the property I am looking for is right here max-height. Now once I select a property I need to choose a Duration meaning how long should this animate? Now I am going to type in .5 seconds, although you can use milliseconds if you prefer. For the Delay I am not going to do anything, I don't want there to be any delay of the animation to occur as soon as somebody hovers over this. We have a Timing Function which is basically easing.
Now if you are wondering what easing is it's how should the animation actually animate, should it speed up at first, should it speed up towards the end of the animation, should it slowdown, that sort of thing. I am going to choose ease. And then for the End Value I am going to type in 999 pixels. None of these boxes are going to be 999 pixels tall, what I'm doing is I am basically saying, hey, you're allowed to be that tall if you want to be. But what it's going to do is it will extend to its full height and then it will stop, it won't go past that and extend to 999 pixels, that just the upward ceiling, remember the property is maximum height.
All right, believe it of not, that is literally it, that's all we have to do. I am going to go ahead and create that transition and we are done. I am going to do a Save All, and I am going to preview this in my browser. When I scroll down and hover over one of these now, notice it animates down as I hover off of it, it animates back into place, and it's going to do that for each one of those where the condense class is applied. If that condense class isn't applied you don't get that functionality. So how cool is that, it's so super easy to do.
Now if you ever want to tinker around or modify with the transitions that you have, even if you have hand-coded those, you can do that quite easily. I am going to switch back into Dreamweaver really quickly. And you'll notice that within our CSS Transitions Panel we see this one being listed. So if you have to hand-coded that it would still pick it up in this panel and allow you to edit it visually, this is how cool this panel is. If I double-click hover, it's going to bring the same dialog box back up and now I could add more properties or I could change things, like I could make the Duration .75 seconds if I wanted to. You can save the transition, do a Save All again, and if I go back into my browser the animation is going to take just a little bit more time, I probably should have made it like 2 seconds so you could really see it, but you also take my word for it.
So the CSS Transitions themselves, if you want to see what these transitions look like you can see there is a section.condense and there are all the transitions. These are called vendor prefixes, and since CSS Transitions are so new, a lot of the browsers actually use vendor prefixes to support them until the syntax is standardized. So here we have our transitions. You will notice that it says max-height, there is the length of it, there is the easing that we are using, and there's the delay, in this case no seconds. Now the actual selector for hover, because we weren't really paying attention to it, it placed it at the very, very bottom of my code.
You can see for example, there is section.condense:hover, max-height: 999 pixels, and that is all there is to a transition. So you could certainly code this by hand if you wanted to or you could go over to CSS Styles Panel and code them as well. But having the convenience of the CSS Transitions Panel means that you can experiment with the settings and the rules are at much faster pace. And it ensures that if you're new to CSS that you're using the proper syntax. It doesn't mean that you won't run into problems, as I mentioned earlier if I had known about the browser support issues of height and transitions, I would have been pretty frustrated.
So be sure to take time to test any transitions that you create thoroughly in multiple browsers.
Get unlimited access to all courses for just $25/month.Become a member