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

Creating rounded corners with background graphics

From: Dreamweaver CS3 Beyond the Basics

Video: Creating rounded corners with background graphics

When working with CSS based layouts it's very easy to fall in the routine of having all of your elements inside of rectangular boxes. Now this can lead to layouts that seem rather stale. So our last background graphic technique will involve creating a rounded corners and let's take a look at the element on the page whose corners we are going to round. The Current Show content area right now is in a sort of darker tan rectangular box and while it's not unattractive it's not really lighting anything up rather. So we're going to round the corners and add a little bit of a shaded effect to the corners too to give it a little bit of added depth. One of the ways to achieve this is just to do a background graphic that is quite frankly a rounded rectangular box and put it behind the entire element. The problem with that is what happens if you are going to add more paragraphs to it. What happens if this content grows and all of the sudden your graphic doesn't fit the content. So we're going to use a nice little technique here that allows us to have content that can stretch vertically but still maintain those rounded corner edges and the trick to this technique is in actually looking at the structure of the element itself. So I am going to click inside the Current Show headline. So we're still working on our index_background Exercise File and I am going to switch over to Code View and in Code View we'll take a closer look at the current div tag. So if we scroll down a little bit so that we can see the whole thing. We see that we have a div with id of current. Inside that we have a heading 1, a heading 2 and then some paragraphs. Now I want you to pay particular attention to the last paragraph because it has a class style applied to it called last and we're going to use that to our advantage. Essentially what this technique allows us to do is will give one overall background graphic to the entire current div tag. We'll then take the Rounded Corner background graphic and apply to our first element which in this case is h2, then we'll take our second background graphic and apply it to the last element and in this case it's the paragraph with the class of last. Now that's what gives us the flexibility of having extra code in here or having a stretch vertically. All we need to do is make sure that the last paragraph or the last element always has that class style applied to it and with those rounded corners. Now before we actually go into the CSS of this, I thought it would be helpful to actually look at the images.

Creating rounded corners with background graphics

When working with CSS based layouts it's very easy to fall in the routine of having all of your elements inside of rectangular boxes. Now this can lead to layouts that seem rather stale. So our last background graphic technique will involve creating a rounded corners and let's take a look at the element on the page whose corners we are going to round. The Current Show content area right now is in a sort of darker tan rectangular box and while it's not unattractive it's not really lighting anything up rather. So we're going to round the corners and add a little bit of a shaded effect to the corners too to give it a little bit of added depth. One of the ways to achieve this is just to do a background graphic that is quite frankly a rounded rectangular box and put it behind the entire element. The problem with that is what happens if you are going to add more paragraphs to it. What happens if this content grows and all of the sudden your graphic doesn't fit the content. So we're going to use a nice little technique here that allows us to have content that can stretch vertically but still maintain those rounded corner edges and the trick to this technique is in actually looking at the structure of the element itself. So I am going to click inside the Current Show headline. So we're still working on our index_background Exercise File and I am going to switch over to Code View and in Code View we'll take a closer look at the current div tag. So if we scroll down a little bit so that we can see the whole thing. We see that we have a div with id of current. Inside that we have a heading 1, a heading 2 and then some paragraphs. Now I want you to pay particular attention to the last paragraph because it has a class style applied to it called last and we're going to use that to our advantage. Essentially what this technique allows us to do is will give one overall background graphic to the entire current div tag. We'll then take the Rounded Corner background graphic and apply to our first element which in this case is h2, then we'll take our second background graphic and apply it to the last element and in this case it's the paragraph with the class of last. Now that's what gives us the flexibility of having extra code in here or having a stretch vertically. All we need to do is make sure that the last paragraph or the last element always has that class style applied to it and with those rounded corners. Now before we actually go into the CSS of this, I thought it would be helpful to actually look at the images.

So you know what is being assembled. So we're going to jump over to Photoshop and take a quick look at those and then we'll come back in and work on the cascading style sheets. Here in Photoshop are the three background graphics. The top one notice is not very tall. It just contains the top rounded corners. The graphic in the middle is much taller than we think we're going to need it. We want to make that as tall as that content might ever be and that way as the content stretches down, we still have that background graphic. So it's good that taller than the actual content necessary. The bottom background graphic contains just the rounded corners on the bottom. So these three background graphics will be assembled into our current div element. Now back in Dreamweaver, I am going to switch over to our layout_background.css file again, so we can add some styles here. And since we're working with current we are going to need to find that area. And again since we structure the styles so that they are in the order they appear in our file, they are pretty easy to find. So right after favorites and we can find current and there it is. So the first thing we're going to do is we'll go ahead and apply the background graphic to the overall current div tag and after the existing margin, let's go ahead and add a new rule to our selector and we're just going to use background and once again, the only thing that this is going to have is URL. So I'll use the Browse feature that Dreamweaver gives me to go in the Images directory. And I am looking for the current_bg.gif file. That's the one we're just looking at and I'll choose that and Save our file. If I switch back to the index_background page and switch over to Design View we can see that we have now got that background graphic. Now it is definitely the same background color so we might need to preview that in the browser to accurately see those edges.

Let's go and preview that in the browser. And as I do that you can see on the very edges here we got a little bit of a shadow or little bit of definition and that's going to help to give it a little extra kick. So we'll close our browser and we'll go back into Dreamweaver and we'll work on adding our rounded corners. Now we already have selector for h1, so we don't necessarily need to add another selector. We just need to do another modification. So for the current h1 selector, I'll add a new line to that and I'll type in background again, and once again I'll type in the URL and we'll browse out to the current_top_bg. So current_top_bg.gif file and we'll choose that one. We need to remember to go ahead and give this some positioning. So we are going to tell it to no-repeat and we're going to tell it position top left. This is actually a really good idea no matter what background graphic, even if you want your background graphic to tile, telling it repeat is really not a bad idea because what that allows you to do is as you are reading through your code you know that hey I did want this background to tile. So I am actually going to go back up to our current one and where we didn't really specify anything up there.

I am actually just going to tell it to repeat along the Y axis. I don't need to give it any positioning information but I am going to repeat it along the Y axis. That way if for whatever reason the current even though it has a fixed width right now if they decide to stretch it later on it's still just going to repeat right on that Y axis and not tile horizontally. So that gives us our top rounded corners. We're going to go down to the very bottom of our current styles and there is current p now. We can't modify just the paragraph because it will give rounded corners to each paragraph. We need to do that in a class selector. So we're going to add a new rule here. So type in #current p.last.

What we're doing is we are doing a descendant selector that has the id of current and inside that it's looking for any paragraph with the class last applying to it. So are going to open a curly brace. That was going to be a pretty simple rule as well. We'll type in a background and we'll do URL and I am going to browse again and this time we're going to find the current_btm_bg. So current_btm_bg.gif. We we'll choose that one. As we did with our top line we will add a no-repeat to this. We really don't want this to tile at all and this time we're going to change the positioning. We are actually going to position it against the bottom left corner, bottom and then a space and then left. Now what that does is it takes the bottom left hand corner of the graphic and it aligns it to the bottom left hand corner of the element. That's really important so that our background graphic for the rounded corners on the bottom snaps down to the very, very bottom of the container element. And the last thing we are going to do is we'll add a little bit of padding and some margin.

So I'll go ahead and do a padding and I don't want padding all the way around. I just need padding on the bottom and what that will do is it will keep the paragraph content away from the background graphic so that your content doesn't run up over those corners. So let's say padding-bottom and we'll just do 2ems and that's about two lines over the space there. And the last thing we're going to do is we'll apply a margin of zero. It will go ahead and zero any margin that the paragraph has on the bottom of it. Because remember just above this in a current p selector if we are giving our paragraphs 1.2ems worth of top and bottom margin to space them out. Well, we don't want our last paragraph spaced out because that would push it even further away. So we'll go ahead and close our curly brace, save the file and when we switch back over to index_background. There is our rounded corners. So we'll preview that in our browser just to make sure everything is working properly and there you go.

There is our rounded corners. Now just to make sure that the technique is working properly I will close Firefox and I am going to go ahead and add another paragraph to this and I am just going to say Testing rounded corners. Now we can see that we've got two rounded corners now. So the paragraph that used to be the last one isn't the last one any more. So I need to go ahead and take off that style. So I'll click directly in the paragraph and using Dreamweaver's Property inspector, I can actually grab the Style pulldown menu. I can go all the way at the top to say None and it will remove any existing class style. So Dreamweaver is really cool in the ability to add classes and then take those classes away when you don't need them any more. So just like that we'll save our file and we'll test that in our browser as well and notice that even though it's taller now our rounded corners are still displaying properly. So we have to remember to change those class selectors and that's the real tricky part of that technique. If you are using server side generated content you might need to use some JavaScript to go ahead and apply that class to the last element in this dynamically. So our layout is almost done. Our last task is to style the navigation and we'll do that in our next exercise.

Show transcript

This video is part of

Image for Dreamweaver CS3 Beyond the Basics
Dreamweaver CS3 Beyond the Basics

102 video lessons · 38680 viewers

James Williamson
Author

 
Expand all | Collapse all
  1. 2m 3s
    1. Welcome
      1m 17s
    2. Using the exercise files
      46s
  2. 1h 23m
    1. Reviewing the Coding toolbar
      8m 42s
    2. Customizing the Coding toolbar
      9m 52s
    3. Taking advantage of Code Hinting
      7m 20s
    4. Using snippets and shortcuts
      11m 10s
    5. Using the Quick Tag Editor
      5m 18s
    6. Using Find and Replace
      9m 50s
    7. Regular expressions
      5m 39s
    8. Using Bridge with Dreamweaver CS3
      8m 28s
    9. Round-trip editing with Photoshop CS3
      3m 40s
    10. Leveraging image variables in Photoshop CS3
      7m 32s
    11. Integrating external variables into your workflow
      6m 16s
  3. 37m 26s
    1. Understanding the CSS Styles panel
      7m 59s
    2. Understanding the Cascade
      5m 50s
    3. Understanding Inheritance
      5m 8s
    4. Understanding Specificity
      7m 5s
    5. Managing CSS styles
      5m 4s
    6. Using Design-Time style sheets
      6m 20s
  4. 2h 19m
    1. Using the new CSS template pages
      5m 59s
    2. Understanding DIV tag structure and layout
      12m 0s
    3. Understanding the CSS box model
      10m 0s
    4. Using absolute and relative positioning
      8m 35s
    5. Understanding floating elements
      7m 9s
    6. Clearing floats
      7m 19s
    7. Using floats to control page layout
      3m 45s
    8. Building structure and assigning IDs
      10m 19s
    9. Applying basic styling to structured content
      11m 14s
    10. Positioning container elements
      11m 4s
    11. Enhancing layouts with background graphics
      11m 48s
    12. Creating faux columns with background graphics
      8m 55s
    13. Creating rounded corners with background graphics
      9m 17s
    14. Building navigation with CSS
      16m 57s
    15. Using Dreamweaver's Browser Check feature
      5m 31s
  5. 53m 22s
    1. Creating properly structured forms
      6m 30s
    2. Creating accessible forms
      6m 41s
    3. Using CSS to lay out form structure
      7m 40s
    4. Creating vertical columns for form elements
      7m 48s
    5. Adding user feedback
      5m 52s
    6. Applying advanced styling to forms
      8m 11s
    7. Client-side form validation
      4m 17s
    8. Validating forms with the Spry Validation tools
      6m 23s
  6. 1h 20m
    1. Understanding the Spry framework
      3m 43s
    2. Defining a data source for use in Spry
      3m 56s
    3. Creating a Spry table
      8m 8s
    4. Using the Spry widgets
      8m 11s
    5. Connecting various data sets
      4m 50s
    6. Understanding Spry widget structures
      7m 1s
    7. Applying custom styles to Spry widgets
      6m 24s
    8. Applying additional custom styles to Spry widgets
      8m 46s
    9. Controlling Spry widget behaviors with JavaScript
      6m 0s
    10. Controlling Spry widget animations with JavaScript
      9m 31s
    11. Creating effects with Spry behaviors
      4m 42s
    12. Hand-coding Spry
      9m 11s
  7. 1h 11m
    1. Creating a base template
      8m 6s
    2. Creating editable attributes
      6m 26s
    3. Creating a new page from a template
      7m 42s
    4. Applying a template to an existing page
      4m 36s
    5. Creating nested templates
      5m 24s
    6. Using repeating regions
      6m 34s
    7. Creating editable and non-editable optional regions
      6m 0s
    8. Using template parameters
      7m 26s
    9. Using template expressions
      9m 59s
    10. Using conditional template expressions
      8m 54s
  8. 54m 40s
    1. Examining XML structure
      2m 44s
    2. Creating an XML document
      9m 9s
    3. Using the CDATA structure
      5m 7s
    4. Creating an XSLT file
      4m 33s
    5. Binding data from an XML to an XSLT document
      5m 6s
    6. Inserting repeating regions into an XSL document
      5m 16s
    7. Creating a client-side XSL transformation
      2m 52s
    8. Styling a remote RSS feed
      7m 29s
    9. Creating a server-side XSL transformation
      5m 31s
    10. Writing XSL expressions
      6m 53s
  9. 1h 2m
    1. Overview of building dynamic websites
      1m 35s
    2. Installing PHP, MySQL, and Apache on Mac
      3m 22s
    3. Installing PHP, MySQL, and Apache on Windows
      3m 54s
    4. Creating a MySQL database
      3m 16s
    5. Defining a testing server and database bindings
      6m 14s
    6. Creating a database recordset
      4m 35s
    7. Adding dynamic content to the page
      5m 14s
    8. Creating repeating regions of dynamic content
      7m 6s
    9. Filtering database records
      7m 39s
    10. Using the Live Preview
      10m 22s
    11. Passing URL parameters
      4m 23s
    12. Dynamically generating links
      5m 18s
  10. 57m 9s
    1. Understanding behaviors
      5m 16s
    2. Installing additional behaviors
      3m 39s
    3. Planning to create a custom behavior
      3m 42s
    4. Examining existing behaviors
      5m 32s
    5. Building a behavior function
      7m 23s
    6. Creating an Action file
      6m 48s
    7. Enabling behavior functions
      9m 1s
    8. Initializing the user interface for a behavior
      3m 9s
    9. Loading behaviors in Dreamweaver
      6m 47s
    10. Testing and debugging behaviors
      5m 52s
  11. 27m 12s
    1. Running reports
      7m 41s
    2. Checking and validating links
      3m 40s
    3. Using cloaking
      5m 42s
    4. Using Check In/Check Out
      4m 3s
    5. Using Design Notes
      6m 6s
  12. 20s
    1. Goodbye
      20s

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 CS3 Beyond the Basics.

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.