Viewers: in countries Watching now:
Join Joseph Lowery in Site Navigation with CSS in Dreamweaver as he explores current design trends in site navigation and shows designers and developers how to create robust CSS-based navigation. The course shows how to convert HTML lists to graphical controls that integrate seamlessly with an existing site design, and how to build menus with a wide range of navigation options, all in standards-compliant CSS. Exercise files accompany the course.
While the ability to incorporate background images in navigation gives web designers a great deal of flexibility, it's also a tad annoying. Any changes mean breaking out your graphics program, finding the source file, and crafting the updates, and then exporting the images and testing. Wouldn't it be great if you could just create tab navigation with rounded corners and complex gradients all in Dreamweaver? Well, with CSS3 you can. In this video, I am going to create the tab navigation we built using the Sliding Door technique in the Chapter 03 video "Setting up adjustable backgrounds" that you can see here.
We'll start with the css3nav.htm file. Now, I have all the basics in place, so we can just concentrate on the CSS3 enhancements. Notice that I have hovers happening, and my background colors changing. Pretty simple. So let's go to Split view and I am going to go up to the anchor tag here, which is nav li anchor (a) and I am going to add a couple of rules. Now the nice things about this with Dreamweaver is it has full code hint support. So if I type in -webkit, you can see that that first comes up, and if I hit webkit, I get a full list of all the webkit browser-specific properties.
So the one we are looking for is border and we actually want the top-right so let me scroll down to here, border- top-right-radius, and we want to set that to eight pixels. This is going to give our top-right corner a rounded radius of eight pixels, and we want to do the same thing for the top-left, so I am going to do -webkit and then hit return and just start typing border and locating the top-left radius and also making that eight pixels. Now, not only does it support the Safari webkit rendering engine, but Dreamweaver also has support for Mozilla, which creates of course the Firefox browsers.
So it's -moz and the syntax here is border-radius topright and topleft. We of course want these to match, so I am going to go ahead and make those eight pixels and then do the one for the other border radius, which is topright, also making that eight pixels. Now I mention that this is a CSS3 property, so it is in the spec. And if all browsers get around to supporting it, we want to make sure that we already have that built in so we're not just targeting Safari and Firefox browsers.
So we'll put in the generic, if you will, CSS3 properties, which is border-top-right-radius, and there is the code hint support for that. And of course we are going to make that eight pixels, and we also want to do the same thing for the topleft. Okay, so if we go over to Live view here--I am going to just shrink down so you can see everything--notice we have very nicely rounded corners there, without any images. And now we are also ready to address the gradients without using an actual background image--although we do need to employ the background image property.
So I am going to go to Full Code view because the syntax for the background image gradient is kind of lengthy. But this also goes to the anchor tag and after all of our properties that we used to create the rounded corners, we'll put in a background image property to start. And then for a value, we'll start by putting in a webkit-specific value, and unfortunately there is no code hint support here, so you'll have to put in webkit-gradiant, and this is followed by a set of parentheses. Within the parentheses, we say what type of gradient it is, and this is going to be a linear gradient. And where does it start? It starts at the left top, comma, and it goes to the left bottom, comma.
Now, what's the color range? Well, it goes from, the keyword, and then in parentheses, whatever you're starting with, and in this case we're starting with the white. Close the parentheses comma, to, and then whatever the final element is, and in this case it is a hexadecimal value of e4e4e4. I need one more parentheses to complete this and then a semicolon. Now, that will handle the gradients for webkit. There is a different syntax for Mozilla, but it also uses the background image property.
So we start with a -moz and the type is actually put in the name of the property here, so it is linear-gradient and we have a parentheses set. Now instead of doing directions left top, left bottom, Mozilla actually works by degrees. So in order to get a linear gradient you put in -90 degrees, or deg, followed by the two colors the top color, which is going to be #fff, and the bottom color, which again will be #e4e4e4.
So now let's close that out with a semicolon, and let's head back to Design view and see how we are doing. Well, you can see the gradient is already in place, and when I hover over it, I go back to the solid color, so I am going to have to add another rule to handle that gradient, but it looks pretty good. We are going right from white to this light tan and pretty effective I think. So let's go back to code and will add in one more rule to make sure that we take care of the hover state.
So you'll notice right below our pretty lengthy nav li a selector is the nav li a hover selector, and that's exactly where will need to put in the code for the gradients, so we can get a reverse gradient here. And I am going to go ahead and just copy this, because it's the same syntax it's just different values, and paste that in. Now, I am just going to reverse the two colors. So instead of fff here, I'll make this e4e4e4 and we'll switch this to fff, and then we'll do the same thing for Mozilla.
In this case, I'll just cut that and then paste it in. All right, so let's take a look at it in Live view, and now you can see that the background gradient switches on hover as well. Now, the cool thing is that these navigation buttons are just as flexible as those built with the Sliding Door technique. So if I go to Split view, and let's click on products here and make that Products and Services, and again we'll change services to the Contact Page and just go strictly to Design view, you can see that the button stretches the way that we would hope it had.
Now granted this CSS3 functionality is restricted to just the latest Firefox and Safari browsers, but if you need to, you can replicate it with an Internet Explorer gradient filter. I think this peek into some of the CSS3 features is quite instructive in terms of what's coming in the near future. I hope you agree.
There are currently no FAQs about Site Navigation with CSS in Dreamweaver.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.