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

Incorporating floated elements

From: Layouts with CSS in Dreamweaver

Video: Incorporating floated elements

As covered earlier in this course, the CSS float property is critical for multiple column layouts. The same property can be used to modify the design of content areas. You'll recall that the float property takes an element out of the document flow, moves it to the right or left, and allows text to wrap around it. Let me show you two different uses of the float property. First we'll take a look at the final version of the page we're going to be working on and as I scroll down you can see the first of the float elements, which is this pullQuote here on the left, and then as I move down, you'll see a very common use of the float property, as it's applied to an image, which in this case is floated to the right of an unordered list.

Incorporating floated elements

As covered earlier in this course, the CSS float property is critical for multiple column layouts. The same property can be used to modify the design of content areas. You'll recall that the float property takes an element out of the document flow, moves it to the right or left, and allows text to wrap around it. Let me show you two different uses of the float property. First we'll take a look at the final version of the page we're going to be working on and as I scroll down you can see the first of the float elements, which is this pullQuote here on the left, and then as I move down, you'll see a very common use of the float property, as it's applied to an image, which in this case is floated to the right of an unordered list.

Okay, let's close this out, so we can get started on building that ourselves. The first thing I'm going to do is position my cursor in between these two paragraphs here and I'll place my cursor right at the start of that second paragraph. And now I'm going to insert a div, so I'll go up to the menu this time, choose Insert>Layout Objects>Div Tag, and I wanted to go at the insertion point. Now this is going to be a class, because I could use multiple pullQuotes on the page. So I'm going to enter in just pullQuote, notice that in this circumstance I don't need to put in a leading period for class or leading pound sign for ID, I just put in the class name.

We haven't defined the CSS Rule for a pullQuote yet, but I can do that right from this dialog box. So I'll just click New CSS Rule, and when that dialog box comes up, it has pre-chosen class as a Selector Type, which is correct, entered in the .pullQuote name for the selector name, also correct, and asks if I want to keep it in the Main.CSS, and I do. So we'll click OK, now I have a number of properties that I want to assign to the pullQuote to make it really standout.

I'm going to choose a different kind of type here, let's go with Trebuchet MS, Arial, Helvetica, sans-serif for the Font-family. I'm going to make it 18 pixels tall, so that it will standout quite a bit, let's give it an Italic font style. Now color-wise I'm going to choose the darker brown color here that we see in the California logo, and I'm ready to go to the next category, which is Background, and let's give it a background color that blends in with the same background color as I call out.

Next, we want to go to the Box category, where we can set the width of our floated item. As with the columns, you always want to set a width for any floated element, so this will be 200 pixels Wide, and we're going to Float that to the left, I do want to give it some padding around it to make it standout from the wrapped around text, but I don't want it to be all of the same. So I'll deselect Same for all under Padding and we'll put in 10 for the Top, 10 for the Right, 5 for the Bottom, and 10 for the Left.

Next, I want to add in a Margin Right value to give a little additional space on the right-hand side, and I'm going to give it 10pixels. Finally, let's go to the Border category, and I only want a Top and a Bottom border, so let's deselect all of the Same for all options here, and in the Top we want that to be a solid line, 3 pixels thick, and the same brown that we see in the type.

Same thing for the Bottom, solid, 3 pixels and then the same brown, which we can sample right from the color swatch, okay? Click OK and then click OK and you'll see that it comes in even with the standard Dreamweaver content placeholder text. Let's go ahead and replace that now and I'm going to type in an opening quote, and, "What a wonderful experience! Our family had the best time!" Now I also want to include brief line saying where this is from, so this is going to be from let's say a woman named Ashley S, and in this paragraph I wanted to give it a particular class, so I've highlighted the paragraph from the tag selector, and I'm going to open up that tag using my Quick Tag Editor.

So I'll press Command+T, and after a space type in class, and let's call this testimonial. Now we need to create some rules to handle the design of this callout a little bit better. So the first one I want to address is the actual paragraph that we see here. We want to tighten that up somewhat. So I'm going to create a New CSS Rule, let's make it a little less specific. It will always appear within our main article however, and then click OK.

And I'm going to set the Line-height to 24, so it's not quite a double spacing, and then go over to Box where I can deselect Same for all under Margin, and set the Margin Bottom to 0, so we can tighten up that space between the testimonial and the top of the line there. Click OK, and that goes part of the way there. Let's go into testimonial, now let me select the paragraph with the class testimonial and create another new rule. Again, make that a little bit less specific and all I want to do here is align the text to the right, and you do that in the Block category.

Okay, And there's our pullQuote. Now let's go down and we'll add in the image. So we want that to appear just to the right of this listing, so I'm going to place my cursor right in front of the text that's part of our H3 heading and then choose Insert>Image and it's called olives.jpg, and there it is. So we'll click that and give it the alt text of Olives. Now I'm going to give this a particular class, so that I can control it.

Again, I'll select it and then go down to Image and select that from my Tag Selector and press Command+T to bring up the Quick Tag Editor or Ctrl+T if you prefer on the PC, and let's put in a class of articleImage. Now my article image has already been previously defined to Float right, so that I can collect that find that again, because I assume that there are other article images here. So sometimes you'll encounter a situation where there's already a mechanism setup for you.

A class if you will that you can then plug-in and it will have the necessary padding; in this case the padding is 1em from the Top, 0 on the Right, 1em on the Bottom, and 1em on the Left. Let's take a look at this in Live View, my callout looks pretty good, my pullQuote looks pretty good, and the image here looks pretty good as well. If your floated elements are in the middle of the content, as these two examples are, you probably won't need to clear the floats.

However, if there's a chance that they will expand beyond the containing element, it's best to add an overflow auto property to the container to handle that issue.

Show transcript

This video is part of

Image for Layouts with CSS in Dreamweaver
Layouts with CSS in Dreamweaver

30 video lessons · 21425 viewers

Joseph Lowery
Author

 

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 Layouts with CSS in Dreamweaver.

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.