Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Creating CSS-based rollovers

From: Dreamweaver CS6 Essential Training

Video: Creating CSS-based rollovers

Although we aren't going to do anything in this movie that we haven't already done in one form or another, stick with me, because in this movie we're going to tie everything that we've learned about styling links together to explore making CSS-based rollovers. We'll focus on a background image based rollover, but the same techniques that we're going to use here would also work with background colors or foreground colors. The ability to create CSS-based rollovers is based off of the use of what we call pseudo selectors. There are many different pseudo selectors, but the link, visited, hover, and active pseudo selectors allow us to respond to user interaction on our links.

Creating CSS-based rollovers

Although we aren't going to do anything in this movie that we haven't already done in one form or another, stick with me, because in this movie we're going to tie everything that we've learned about styling links together to explore making CSS-based rollovers. We'll focus on a background image based rollover, but the same techniques that we're going to use here would also work with background colors or foreground colors. The ability to create CSS-based rollovers is based off of the use of what we call pseudo selectors. There are many different pseudo selectors, but the link, visited, hover, and active pseudo selectors allow us to respond to user interaction on our links.

In the past we've needed to be very careful in how we added these pseudo-selectors as browsers were very inconsistent in how they handled visited links. Now the browsers have more or less standardized how visited links are handled we can use the hover pseudo selector to control user interaction on links without worrying about the negative effects of visited links. So I have the index file open from the 08_07 folder and you may notice that I'm already in Split Screen view and that's because before we start talking about creating rollovers I want to discuss very briefly the styling of links themselves.

You may have noticed that one of the most common techniques for styling links is to remove the default underline that links have. The easiest way to do that is just in a generic link selector as we have here with the a tag, you just set text-decoration to none. That is all there is to that. It's incredibly simple thing to do. I'm going to switch back to Design view and I'm going to turn Live view on, and I'm just going to scroll down a little bit, because what I'm interested in styling are these guys right here. I want to do a CSS based rollover for these particular links.

Now I'm going to go over to the CSS Styles panel and I'm a big believer in keeping things as simple as you can. So what I'm going to do is I'm going to select the existing a selector which is up towards the top of my styles and I'm going to create a brand-new CSS rule, and of course the reason that we're focusing on this is so that it'll create the rule just underneath it. That's going to help me keep things organized. So I'm going to do New CSS Rule. Now most the time you're going to pick a selector based on what you're trying to style on the page. In this case, I really want to do a very generic selector.

So even though we're going to be styling a tag; in this case the anchor tag, it's actually more appropriate for us to choose Compound, because Dreamweaver has a list of all those pseudo selectors right there built-in to the selector name, which is very nice. I'm just going to use a:hover and that's going to control the styling of this link anytime the mouse hovers over a generic link. I'm going to style that in main.css and I'm going to go ahead and click OK. Now what I want to do here is I want to use that orange color so every time somebody hovers over one of our links I want the color of the text itself to change to orange.

So what I'm going to do is I'm going to go right here into our Type category and for Color I'm going to type in rgb and then in parentheses (251,174,44). I'm going to close my parentheses and click OK. Now as I mouse around my page now all of my links are turning orange, which is great. That's actually what I need everywhere else including up here in the menu.

So that's a nice global setting. I can turn that on to all of my links at the same time and everybody goes ahead and gets that. However, it's not appropriate for everything. That orange looks kind of weird. It has a nice contrast and you can read it on the blue. However, what about one of these guys? This has a link on it, and now when I hover over that, of course, it looks like it's going away because the orange blends in with it. So since we have so many of these different info boxes that have links in them some of them, the orange looks okay in, some of them the orange just kind of goes away.

So I want to control that by not only changing the color of the links when I hover over them, but replacing that color with a background image that's still going to give me a nice hover effect. So in order to do that I'm going to scroll up through my styles and what I'm looking for is right there, section.info a:hover. So essentially it's saying when any link is hovered inside of a section with the class of info, let's apply that. So it's going to apply it to every single one of these little pods.

So I'm going to go ahead and select that rule and double-click it so I can edit that. Now the first thing I'm going to do is change the color. I want to keep color white. So even though the default color of the links is white I'm going to have this background image that shows up. So that's okay, and in this way I don't have to worry about contrasting with all the multiple colors that are inside these section boxes. The next thing I'm going to do is switch over to the Background category and I'm going to browse for a background image. Inside the 08_07 directory I'm going to go into the images folder and I'm just going to scroll through until I find that diagonal pattern.

Then I'm going to go ahead and click OK. Now I do want this to repeat, so I'm not going to change any of these settings here. I'm going to go ahead and click OK. As soon as I do that I can do a Save All and then just having Live View on is fine. Now when I come over here to find out more, notice when I hover over that I get that diagonal background image and it gives a nice little hover effect. It's not as obvious in some of the other info palettes; you can see it sort of there, it's very subtle in that one whereas in other ones it's quite obvious. But it's kind of a nice little effect. It's very subtle, but it still gives the user feedback on the fact that they are hovering over that particular element.

Now whether you're creating a menu, changing the default styles of all the links on your page, site-wide, or just creating a group of rollovers using the hover pseudo selector allows us to create dynamic rollovers quickly without using any JavaScript at all.

Show transcript

This video is part of

Image for Dreamweaver CS6 Essential Training
Dreamweaver CS6 Essential Training

90 video lessons · 54223 viewers

James Williamson
Author

 
Expand all | Collapse all
  1. 1m 4s
    1. What is Dreamweaver?
      1m 4s
  2. 5m 44s
    1. Welcome
      1m 4s
    2. Using the exercise files
      2m 17s
    3. Learning web design
      2m 23s
  3. 1h 0m
    1. Looking at the Welcome screen
      5m 9s
    2. Exploring Windows and Mac interface differences
      5m 6s
    3. Arranging panels
      8m 44s
    4. Managing workspaces
      10m 14s
    5. Exploring the Application toolbar
      6m 21s
    6. Exploring the Document toolbar
      8m 47s
    7. Working with the Property inspector
      9m 30s
    8. Using the Insert panel
      6m 30s
  4. 53m 3s
    1. Understanding basic site structure
      3m 46s
    2. Exploring file naming conventions
      2m 10s
    3. Defining a new site
      5m 23s
    4. Managing files and folders
      7m 57s
    5. Adding remote servers
      7m 4s
    6. Uploading files
      12m 46s
    7. Previewing in browsers
      9m 11s
    8. Managing multiple sites
      4m 46s
  5. 36m 41s
    1. Creating new documents
      6m 49s
    2. Setting up new document preferences
      5m 30s
    3. Setting accessibility preferences
      6m 49s
    4. Working with starter pages
      4m 32s
    5. Managing starter pages
      13m 1s
  6. 37m 23s
    1. Getting text into Dreamweaver
      8m 43s
    2. Importing Word documents
      4m 6s
    3. Adding structure to text
      7m 35s
    4. Creating lists
      4m 35s
    5. Creating definition lists
      4m 0s
    6. Using the Quick Tag Editor
      8m 24s
  7. 44m 41s
    1. Exploring the Code toolbar
      5m 41s
    2. Setting code preferences
      7m 19s
    3. Using code hints
      8m 8s
    4. Wrapping tags
      5m 7s
    5. Adding comments
      6m 29s
    6. Using snippets
      7m 32s
    7. Formatting source code
      4m 25s
  8. 1h 19m
    1. Setting CSS preferences
      9m 32s
    2. An overview of the CSS Styles panel
      9m 23s
    3. Creating a new CSS rule
      6m 42s
    4. Using the CSS Rule Definition dialog
      7m 25s
    5. Organizing styles
      7m 22s
    6. Modifying style properties
      6m 17s
    7. Controlling CSS through the Property inspector
      6m 37s
    8. Attaching external style sheets
      5m 54s
    9. Using CSS visual aids
      7m 3s
    10. Using CSS Inspect
      6m 48s
    11. Using the Code Navigator
      6m 39s
  9. 1h 11m
    1. Managing assets in Dreamweaver
      7m 30s
    2. Setting external image editing preferences
      4m 26s
    3. Placing images on the page
      10m 12s
    4. Exploring Photoshop integration
      7m 17s
    5. Modifying Smart Objects
      9m 42s
    6. Modifying image properties
      8m 4s
    7. Styling images with CSS
      6m 45s
    8. Using background graphics
      7m 28s
    9. Positioning background graphics
      10m 10s
  10. 36m 23s
    1. Link basics
      3m 17s
    2. Setting site linking preferences
      2m 19s
    3. Creating links in Dreamweaver
      9m 17s
    4. Using absolute links
      3m 43s
    5. Using named anchors
      6m 41s
    6. Creating an email link
      5m 25s
    7. Creating CSS-based rollovers
      5m 41s
  11. 44m 30s
    1. Reviewing table structure
      5m 20s
    2. Importing tabular data
      6m 46s
    3. Creating accessible tables
      6m 11s
    4. Exploring basic table styling
      9m 42s
    5. Styling alternate rows
      8m 57s
    6. Creating custom table borders
      7m 34s
  12. 59m 15s
    1. Understanding how forms work
      2m 45s
    2. Reviewing form design
      3m 44s
    3. Creating accessible forms
      5m 16s
    4. Setting form properties
      2m 39s
    5. Using the fieldset and legend tags
      2m 52s
    6. Inserting text fields
      6m 56s
    7. Inserting list menu items
      7m 54s
    8. Inserting checkboxes
      4m 14s
    9. Inserting radio button groups
      3m 52s
    10. Inserting submit buttons
      2m 25s
    11. Exploring basic form styling
      8m 2s
    12. Exploring form element styling
      8m 36s
  13. 33m 25s
    1. Adding CSS3 transitions
      8m 29s
    2. Spry overview
      2m 44s
    3. Using Spry widgets
      3m 57s
    4. Adding Spry effects
      8m 1s
    5. Using the Widget Browser
      7m 4s
    6. Extending Dreamweaver
      3m 10s
  14. 1m 2s
    1. Additional resources
      1m 2s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
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.


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 "Already a member? Log in

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 Dreamweaver CS6 Essential Training.

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

Your file was successfully uploaded.

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.