Join Chris Converse for an in-depth discussion in this video Adding CSS styles to the text, part of Creating a Sliding Tabbed Panel with jQuery and Dreamweaver.
Now we want to create some CSS rules to style the text inside of the panels. Now, we're going to be using compound rules, which means we want to target only the text that's inside these panels. And Dreamweaver gives us a nice little shortcut to help us write a compound rule. So if have my cursor inside of one of the panels--and I can see on the document tree here that I'm inside of the paragraph tag, inside of panel_content--and we can see this follows all way up to to the div.sp, which is the overall container for our sliding panel. With my cursor inside of here, I come over to this CSS styles property, click on Create New Style, and when we select Compound from the type of list, notice that Dreamweaver will write a compound rule targeting exactly the element I had selected, all the way from the highest-most parent, which in this case is the sp tag.
Now we don't need this to be quite as specific, so let's come in here and let's remove all of the intermediate rules. And we're just going to have .sp--the outermost container--space p. So we want to target the paragraph tags inside of the outermost container for our sliding panel. Next, let's come down here and make sure that we have the sliding_panels.css chosen so that when we write CSS rules here, even though we're in the index.html file, those rules will go into the sliding_panels.css file. Let's click OK. Now for paragraph we're going to come in here to Font-size.
We're going to specify 1 em. And over at the Box properties, let's come in here, and let's uncheck Margin Same for all, and let's add a 0 on the Top, 0 on the Right, we're going to add 1 em on the Bottom, and then 0 on the Left. Now, when I click Apply we can see some slight changes over in the left-hand side here. We can see that we now have these individual paragraphs have no margin at the top. Let's click OK. Let's create one more rule. We want this to be for an h2.
So I'll select a couple of characters in the heading. Come over here, create a new CSS rule, Compound. Let's get rid of all of the intermediate classes, so we have .sp h2. Click OK. What we're going do here for Font-size, we are going to type 1.15 ems; this will give us a 15% increase on the base font size. Box properties, uncheck Same for all from Margin. We're going to type 0 on the Top, 0 on the Right, .5 ems on the Bottom. and 0 on the left, and then click Apply.
Once we do that, you'll see all of the h2 tags now stick right to the very top of the panel because we've removed the top margin. And since the paragraph tags have the top margin removed as well, we're getting exactly half an em between the h2 and the paragraph tag. So let's come over here and click OK. Now that we have the CSS rules in place to style the text in the panels, next we'll work on some CSS rules that will target the layout of the panels.
- Creating the main panel and tab containers
- Adding content to the containers
- Adding CSS styles to the text and tabs
- Adding the jQuery $(document).ready() function
- Assigning click events to the tabs
- Setting an autostart on page load
- Creating custom graphics for the panels
- Assigning custom classes to the HTML elements