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

Positioning multicolored glyphs

From: Deploying Icon Fonts for the Web

Video: Positioning multicolored glyphs

We're almost finished with our multicolored icons. Now let's talk about the properties that we need for this.

Positioning multicolored glyphs

We're almost finished with our multicolored icons. In our last exercise, we structured the HTML for them. So in this exercise, we'll concentrate on the styles. Now I'm going to go into my code editor. And I have the multicolor.htm, open from the 04_06 directory. Now, we're picking up right where we left off. So, if you have the previous file open. And you just want to keep working on that, that's fine. Just as a refresher, to let you guys know kind of, what kind of structure we're dealing with here.

We've got two spans, one is nested inside of the other. The outside span has two classes applied to it. One is multi. To let us know that it is a multicolored icon. And the other one identifies which icon it is. In the case of the one that we're going to be styling, that would be maps. Alright, I'm going to open up my CSS file, which is the base.css. And I'm going to scroll all the way down towards the bottom. Where I'll find my icon font styles. Now, as I get towards the bottom, I've got some commented styles down here for a multi-color colors.

What does that mean? Well for the multi-color icon. These are the colors that we're going to be using. We'll turn our attention to those in just a moment. What I want to do right now, is make sure that our multicolored icons are lining up one on top of the other. So the first thing we're going to do is we're going to write a selector that targets any of the multicolored spans. So we're just going to say span.multi. Open up a couple of curly braces. Now let's talk about the properties that we need for this. The first thing that I'm going to do, is I'm going to set position to relative. Now the reason for that is, in order to have these two stack one on top of each other.

We have to use some pretty fancy positioning tricks. In this case I'm going to use a very old trick. Which is the parent element will get a position, a style of relative. While the nested one will get a position of absolute. Absolute positioning will take an element out of normal document flow. And then position it relative to the nearest positioned parent. I know that sounds really weird. But if you don't have a nearest positioned parent, it's positioned relative to the window itself. So, by giving the parent a position of relative.

We're making sure that the absolutely positioned interior icon lines up with this one. Okay? I know, if you've done that before I know that doesn't make sense. But some of you guys I'm sure have used this trick once or twice before. But trust me when I tell you it, it's going to work. Alright I'm going to do a display property of block. That's going to make sure that these guys are displaying in their own individual space, within the normal document flow. And that I can use box model properties on it. The next thing I'm going to do is give it a width of 64 pixels.

The width value isn't required to display our icons on top of each other. This is more to make sure that it fits within the parent box and is centered. Because the very next property I'm going to apply are my margins. And for margins, I'm going to do 0 for top and bottom. And auto for left and right. Which is going to center it horizontally. Alright, I'm going to go ahead and save that. And now I've got to move on to the interior span. And this is the one that we have to position right on top of this parent one. So for that one, I'm going to do the same selector again.

Span.multi space span. So we're saying hey, let's target any span inside of a span, with a class of multi. Alright, so we're getting pretty specific here. Inside of that, I'm going to go ahead and give it a positioning attribute as well. This one is going to be absolute. And then I'm going to give it a top value of 0, and a left value of 0. And what that's going to do, is it's going to take the interior span, which is the interior icon. And it's going to line it up at the top left hand corner at 0, 0 of its parent.

Alright, I'm going to save this. Preview this in a browser. And if I scroll down. Excellent. So all of my multi-colored icons are overlaying one another. The problem obviously, is they're still multi, they're still single color. So now what we're going to do, is we're going to go back into our styles. And we're going to assign some color. Okay, so I'm back in my styles. And I'm going to scroll down a little bit. And I'm going to un-comment, not the actual comment itself, I need that. I'm going to un-comment out these individual classes down here. Now, these are targeting all of the other icons.

So we need to write our color assignments for our map. And I'm just going to go up to the very top of this, because it's the first element. So I think it probably should be up top. Alright, so I'm going to use the class that we use to identify, which is maps. Now for this one, I'm going to give this a maps a color of #7D7893. It's kind of an off, I don't know, almost pewter blue. I think, is what this is.

And now remember, because the outer parent is maps. Now both of these, the interior and the stacked icon. Both now have this color. So we have to now target the interior span. So I'm going to write a selector that's .maps space span. And I'm going to give it a color as well. And the color for the interior one's going to be sort of a, sort of an off-red, I guess, off-pink. 7B. 3, 1, 2, 3. And then the semicolon.

And feel free to experiment with the colors. And make them any way that you want. You can probably do a better job than me at assigning colors. I'm going to save this, go out to my browser. And as I see, I've got nice, multicolored icons. Well there you have it. Of course, you know, how you actually structure and style your multicolored icons are going to be in large part determined by how they are created. Some, I've actually seen a couple of icon font sets that use what they call, zero width characters. And to do that you just put two spans side by side, display them in line.

And they overlap each other. So there are multiple ways to do this. I, I want you to notice however, that we found a way to do it that fit squarely within the deployment strategy that we had planned for our icon fonts. And that just requires that you understand a lot about the icon font that you're using, and how it's constructed.

Show transcript

This video is part of

Image for Deploying Icon Fonts for the Web
Deploying Icon Fonts for the Web

21 video lessons · 1808 viewers

James Williamson
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 Deploying Icon Fonts for the Web.

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.