Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Currently the Sliding Panels are being styled by a combination of existing styles and the external Spry asset CSS. In this movie we'll add some local styling to make sure our panel groups look the way they're supposed to. Although we'll use embedded styles for the purpose of this exercise, you might want to externalize these styles in your own projects so you can reproduce the widget styling faithfully throughout your site. So I've got the details_start HTML file opened up and I found that in the Chapter 8 directory. So go to Chapter 8, if you're following along with me in the exercise files and open up details_start.
Now I'm just going to switch over to Code View, and I'll go ahead and hide my panels so again I get a little bit more space for my code. And I can see that I already have some embedded styles. I have of a section of thumbnail formatting. And I have a section of parent container formatting and that is the DIV tag that surrounds our Sliding Panels but doesn't really have anything to do with their functionality. So I'm going to start here. Now what I'm going to do- I'll scroll down a little bit further here- is I'll create a new line, right there on line 24, and I'll add another comment to give myself another section here and I'll like sort of spacing them out with some dashes so that they spread the whole length of the page.
I'm going to type in 'formatting for panel content' and then add a few more dashes here for my section. We're going hand code all of this. We're going to use some very specific selectors here because part of the problem with our current panels is that overall document styling is overriding a lot of what I want to happen. And so if we want our styling to work, I can't just use the class names inside the panel groups. I have to expand that and use some of the selector names that already exist within our file. So that's one of the reasons we're having to write more custom styling here.
So our first selector will be #mainContent, space, .Sliding, capital S, Panels, capital P, Content, capital C, Group, capital G. So be really careful. That's got to be spelled correctly and all the capitalization has to be correct. So capital S, P, C and G. SlidingPanelsContentGroup and it's a class style, class selector. And I hit space and then we're going to do h2. So what we're doing is targeting any header, heading two, inside of our SlidingPanelsContentGroup, which is inside of mainContents. So again a very specific rule that will help us overwrite any of the H2 selectors that exist elsewhere in our site.
So here we're going to do a margin and we'll do margin of 10 pixels for the top, zero for right, zero for bottom and then 220 pixels to the left. Now that may seem kind of weird to you guys, but what we're going to do is use some background graphics for each of those Sliding Panels and this'll push us all the way over to the right so the background graphic can display without the header displaying on top of it. Now I'm just going to keep these all on a single-line. If you prefer to break them down individually, you can. So I'll hit margin and then do another space. Here we're going to do a little bit of padding so I'll choose padding and we're just going to do zero padding all around and then I'll do background of none and that'll take off any default backgrounds that other headers might have. And then finally we're going to do a text align to the left.
Again, that's going to take away the default and so we're done with our heading two and we'll go ahead and close out our curly brace there. So here we've applied some custom margins to it. We've stripped out any padding that other heading two styles might be adding to this. We stripped at any backgrounds that might be existing in prior H2 tags and then we've reset the text alignment to the left. Alright. Let's go down to our next line. And here we're going to do a very similar selector, #mainContent, space, .SlidingPanelsContentGroup, and once you type that, if you really felt like copying and pasting it, you certainly could. And then do the p tag and let's open that up.
So this is going to target our paragraphs that are in our Sliding Panels and again we're using a descendent selector that invokes both the parent SlidingPanelsContentGroup panel and the mainContent DIV tag. So inside that we're going to do a margin and our margin is going to be 1em for the top margin. We're going to do is zero for the right. We're going to do a 1em bottom margin. So that's going to give us our vertical spacing in our paragraphs. And then we're going to do a left margin of 220 pixels. Notice that that is exactly the same as the heading two, so again we're giving enough space for those background graphics to show up.
We're then going to go ahead and give it a padding of zero and then a background of none, so very similar to what we've done prior to this. Then we're going to do a text-align of left, to go and reset that based on what any other selector is doing with our paragraphs. Again, don't forget your curly brace and now we've styled the heading two and the paragraph inside those content regions. The next thing we need to do is go ahead and handle the price. If you remember, we surrounded the price with a span tag so let's go ahead and style that. So we're going to do #mainContent, space, .SlidingPanelContentsGroup, once again remember the capitalization and spelling.
Then do a space, span.price. So we're going to do an element-specific class selector inside the descendent selector. Go ahead and open that up and type in 'display' and set display to block and then a semicolon. And then after that we're going to do font-weight. So we're going to do font-weight. We're going to style that as bold. Another semi-colon. Font-size is going to be 1.4 em's. Text-align is going to be right and finally the margins to the right of 10 pixels, and that'll hold off the edge of our Sliding Panels content.
So we styled the heading two. That's going to be in our panels. We've styled the paragraph and we've styled the span that surrounds the price. So I'm going to save that, flip back over to Design View and if I scroll down, I can see that we've got a lot nicer styling in here. There is our headline, there's a paragraph underneath it. And there's the price element. OK, let's go ahead and the preview that in our browser. And indeed, as we mouse through this, the only thing missing currently is our images. So we're going to have to style some background graphics in just a moment.
You might wonder, "Well, why didn't you just put in an image and then float the text around the image?" Spry widgets are not without their faults and one of the things I've noticed about these animated Spry widgets is that if you have floated elements inside of them, as they animate, the floats tend to become unresolved and then as the animations finish, the floats resolve themselves again. That can cause some flickering on faster animations and on slower animations they cause the text look really different until the animation is finished. So we're avoiding that by going ahead and applying a margin to the heading and the paragraph and then in our next exercise we'll create a background graphic for the image itself.
Our Spry widget is almost finished. The last thing we have to do stylistically is to create a couple selectors to apply background graphics for each of the elements and that's what we'll tackle in our next movie.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 99541 Viewers
56 Video lessons · 112762 Viewers
71 Video lessons · 81574 Viewers
131 Video lessons · 39161 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.