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

Positioning background graphics

From: Dreamweaver CS6 Essential Training

Video: Positioning background graphics

In our previous movie we saw how effective background images can be in enhancing your visual design. In this movie, we are going to explore you can exert more control of your background images through positioning images within their container elements. This allows us to create images that change based on things like user interaction or as we are going to be doing in this example, using a single image for several different elements on the page. So here, I have the index.htm from the 07_09 folder opened up. I have Live View turned on, and I scrolled down to the last series of Info boxes in the sidebar here and I have Connect with us.

Positioning background graphics

In our previous movie we saw how effective background images can be in enhancing your visual design. In this movie, we are going to explore you can exert more control of your background images through positioning images within their container elements. This allows us to create images that change based on things like user interaction or as we are going to be doing in this example, using a single image for several different elements on the page. So here, I have the index.htm from the 07_09 folder opened up. I have Live View turned on, and I scrolled down to the last series of Info boxes in the sidebar here and I have Connect with us.

Now if I hover over these, this one is Follow us! That must be Twitter, Google Plus, that isn't like Google Plus. Be our friend that must be Facebook and then this one is supposed to say LinkedIn Let's connect. So for some reason whatever reason we're only seeing one icon there and I need to change that. Well, the technique that we are going to be using here is a technique called CSS Sprites. And what that is basically is, we take a larger image file and we use it as a background graphic for an element that's rather small in nature. These elements are each 45 pixels by 45 pixels.

So we are only seeing a portion of the image each time we look at it. Now the file that we are going to be working with here, I have the original Photoshop file which is a social_sprite. psd and if I open this up in Photoshop, you can kind of see what I'm talking about here. So in Photoshop you can see that this is actually a much larger image file, and it has several icons inside of it, it has Twitter, it is Google Plus, Facebook and LinkedIn. And those icons are stacked one on top of each other, so we have sort of a default view of it and then we have this sort of almost beveled view that we are going to be using for any type of a hover interaction when people hover over it.

So this technique allows us to do a couple things. Number one, it allows us to use a single image and multiple elements on the page and get a different view from it and that's a little bit more effective and efficient. But the second thing and the most noteworthy thing that this does for us, is it saves server requests. So this image is downloaded once, it's used all over the site and it's used for multiple images. So instead of say four requests per page being made for this particular image only one is being made. That makes a tremendous difference, not only desktop but really on mobile devices.

So this is a technique that's gaining a lot of widespread support in the design community, it has being driven in large way by mobile devices. Although the technique itself has been around and in use for quite some time. Alright, so I am going to go back into my file and we need to start modifying some of our CSS. And we are going to be concentrating on the background position property because all we are doing, we are not going to redefine a different image we are going to use the same image each time. We are just going to move it, we are just going to reposition it within those small elements. Okay, so I'm going to go into my CSS Styles and I am going to scroll down and I am going to find these styles right here, connect twitter, google, Facebook and linked.

Now the first thing I need to do however is I need to revisit my Preferences. So I am going to up to Edit and I am going to choose Preferences. This is one of the reasons why you want to make sure you know exactly what your preferences are doing for you. If I go to CSS Styles, if you remember from earlier in the title, we came in and turned on Shorthand Notation for all these properties. Well, the Background properties what we are going to be working with here. And so I am going to turn that off, the reason I am going to turn this off is if switch over to my main.css and I scroll down through my CSS to find these specific rules, I notice in looking at these that they are empty.

I have sort of a parent rule, if you will up here, that is setting the background image itself. Notice, that we are not setting any positioning values, we are just telling it which item to use and then not to repeat. So the positioning information is going to go in these selectors. However, if I had the Background property applying Shorthand Notation, what it would do is it would kind of overwrite the Background Property up there and the original one. So I don't want to do that, all I want to do is pass in background positioning information. So I am going to go back to Design view, and I am going to find these and I am just going to double-click on Twitter to start off with.

Now if I go my Background properties, I notice that I have the option of setting an X position and a Y position. And so what I can do, is I can grab this X position pulldown menu and I can choose from some keywords. So for the X position which is a horizontal position I can choose left, center and right. I am going to choose left and for the Background-position the Y axis I am going to choose top. So we have three options there top, center and bottom. And what that's going to is, it's going to use the top left-hand corner of the background image and it's going to position it with the top left hand corner of the element.

So when I click OK, I see absolutely no change occur. Now the reason I see no change occurs is because that's the default position for background images. So if I want that default position I don't necessarily have to come out and explicitly say left top, it's going to do that every single time. Now I might go to the next one which is google, I am going to double-click on that and when I go to my Background position with Google I need to do something a little bit different. These icons are each 45 pixels wide, meaning I basically just horizontally need to move over by 45 pixels. Well, you can see there isn't really a keyword that allows me to do that.

But one of the nice things about this is I can enter in a value if I want. So what I am going to do is I am going to enter a -45 pixels for Background-position for X. Now, again you may be wondering why negative? Well, it's basically the direction that you move along that axis. If you move to the left, you will move positive values, if you want to move from the corner to the right you use negative values. You may think that well since the Y position doesn't change, I don't need to enter anything there, but if you do that it's only going to give one value for Background-position and then that value is going to apply equally to both of them.

So you do for Background-position, you want to come in and type in a zero. Now I can double-check it to make sure I have give it the right values and I am going to click Apply. I can see that now I'm seeing Google Plus section of the image not the Twitter section, that's awesome. Alright, so very quickly, we are going to do the next two. For Facebook, I am going to use a Background-position -90, again, I am going just 45 pixels moreover. And a Y position of zero and click OK, I see Facebook show up. And for LinkedIn, now I could keep doing some math, but I was an art major and I hate math.

So now when I go into Background-positioning and since this is all the way over against the right edge, I could come in and say Background-position right, Background-position Y top. Oops I am sure, do top instead of center. Now I click OK and it gives me the same value as if I'd come in and given the numeric value for that. So now, we have our images and these are links by the way. So I when I hover over them, you know I do see the hand show up, but people are often used to seeing visual feedback when they hover over something that is clickable. So if you remember from the Photoshop file, we do have sort of overstate if you will for these icons.

And all I have to do is write a selector that when I hover over this changes the Y position. Now a lot of times it's very easy to come over the CSS Styles panel and set Properties, but sometimes it is a little faster to do things by hand. So what I am going to do is, I am just going to go Code view or it's probably a little easier to use Split Screen view. I am going to collapse my panels down the icons, and I want to scroll over a little bit so I can keep an eye on these social media icons that we have got here. And I am just going to scroll down in my code, until I find this sort of positioning that we had set.

You can see there it is for Twitter, there it is for Google. So I am going to highlight that code, notice I am getting both the opening and closing braces. For some reason there is little bit of extra space there too, so you can feel free to get rid of that. I want to copy this, I am just going to paste it just below it. And then I am going to modify the Selector by adding with no spaces, a :hover to it. Basically what this tells a selector is, hey when somebody is hovering over this element, go ahead and do this and this time, I am going to change the background position from left top to left bottom.

So I am going to save that and then I am just going to go through and do each one of these. And remember, what we're doing is we are changing the Y coordinates this time not X coordinates. So the X coordinate is going to stay the same, so for each one of these I just add a hover and it's called Pseudo-class selector. And then I am going to change my background positioning. Now the same way that we use negative values to move to the right you will also use negative values to move down. So in this case I want to -45 for the Y position. And if you're wondering the horizontal axis comes first in these numbers, the vertical axis comes after that.

Alright, I am going to do same thing for Facebook. I am just copy it, paste it, add the hover. And then, I am just going to mirror this to -90 pixels. And then finally we will do our LinkedIn one, and we will copy that selector. So we can see how easy it is to work in code, this is one of the reasons why after while most designers do gravitate over working with code. Just going to do hover and this time instead of saying right top just like we did for Twitter, I am going to say right and bottom.

Alright, if I save this, go back to Design view, make sure, I am looking in Live View, now when I hover over these, it's changing background position. Now you don't always get everything right the first time out, you can see the little Facebook icon is going away. So I know I made some sort of syntaxial error in there and I am betting that as I was typing that there was at least 90% of you that were saying no, no, no oh yeah he did it. So you know what, no one gets everything right a 100% of the time and yup indeed, I can see automatically what's going on with Facebook, it's not cumulative on the Y axis it's only 45 pixels down for all of them.

So that was me letting my designer self get ahead of me. So once again, I am going to click back in Live view and Design view after saving this. And now Facebook works just fine just like the rest of them awesome. So this is a great technique, but you're not limited to those by learning to control not only background images, but their positioning as well, you can become much more creative with how your background images are integrated into your visual design, you can add compelling techniques like CSS based image rollovers like we did here and be much more efficient with how you're serving your images to different devices and screens.

Show transcript

This video is part of

Image for Dreamweaver CS6 Essential Training
Dreamweaver CS6 Essential Training

90 video lessons · 53623 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.