Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Live view is amazing at helping you understand how your layout will look in most browsers. But trying to troubleshoot your CSS can be frustrating. As the CSS visual aids that we covered in the last movie are disabled when you are in Live view. Well, that's where CSS Inspect comes in. CSS Inspect let's you do just that; inspect the elements on the page and visually explore the box model properties that have been set on the elements. As you'll see, it's an invaluable way to troubleshoot layout issues.
So I have the spotlight.htm file open and that can be found in the 06_10 folder. And I have Live view turned on. Now if I just scroll around my page you know everything looks for the most part okay, but I notice a couple of things right off the bat that are troubling. I have too much space between the headline and the student's name. And everywhere between the elements I have this sort of three pixel spacing that creates the look and feel borders around them, but towards the bottom here, I notice that the space between the footer and elements above it was actually probably about double that.
So I have some problems there that I need to track down. Now with a really complex layout like this one where you have a lot of elements on the page and lot of positioning going on, it can be very difficult to track that down, it can also be really difficult to sift through all the styles we have over here and find out what we are looking for. Now we learned a little bit earlier how to focus on an element and how to go to the CSS Styles panel and see what its properties are. That's one way to start troubleshooting something like this. But it's a little bit more helpful if you know exactly which elements are causing the problem.
So what I am going to do is I am going to come up to my document tool bar and I am going to turn on Inspect mode. Now the only time you are going to see that particular button, that Inspect button, is when Live view is on, when Live view is off it doesn't show up. So I am going to turn Live view on and then click Inspect. Now Dreamweaver is going to give you this little message that says Inspect mode is most useful with certain workspace settings. What it really wants you to do is have the CSS Styles panel open in one side and have the code open on the other, which is fine. It works fine, it works fine that way because you're able to kind of switch back and forth.
But I'm really more interested right now in getting a nice overview of the page so I am not going to turn that on. So as I mouse around I begin to see things you know I am not clicking on anything I am just mousing over elements, that's how you want to use Inspect. But I see overlays when I start mousing over elements. And I see these overlays I see different kind of colors show up. Well, what we are looking at is we are looking at the Box Model properties and that would be the Content, the Margins and the Padding. So let's say I mouse over this image of Gerald Chow. All I see is this translucent blue and sometimes it can look kind of green to depending upon what color of background you are over, that indicates content.
But if I mouse over student spotlight, I see this little yellow band down below, now the yellow indicates margins. And if I mouse up just so that I'm sort of in the parent elements the div with a class of students that's applied, I see all three. On the left hand side down here in the left corner, I see sort of that blue color which indicates content. I see on the far right hand side a yellow which indicates a really big margin which is pushing this over. And then on the top and on the interior right side of it I see sort of this magenta color and that's padding.
So I'm seeing all those elements. So, who is in charge of all the space between these guys? Well, if I hover over the name Gerald Chow I can see there's a fair amount of padding on top of that. If I hover over Student Spotlight I can see that there's a little bit of yellow margin below that and if kind of go back and forth between those two I can see that those are touching each other. So they are actually both responsible for all that space. I have a little bit of a margin below the Student Spotlight that actually looks pretty good, I probably don't want to get rid of that.
But this extra spacing that's caused by padding that's probably the culprit. Now, what if I scroll down and start going over elements on the bottom. Well if just over the image and just see the image if I come down a little bit, then I get a paragraph and if I go over to the left hand side, then I finally get this Container element and I can see that little margin that goes below it. But that margin that goes below it doesn't actually extend down in to the footer. So that tells me this is not the problem. And the one beside it is not the problem and the paragraph is not the problem.
Well, a lot of times, again when you're dealing with these complex structures it's really difficult to tell who is at fault or even which element might be causing the problem. So you end up mousing around a lot, trying to find out who it is and you know the footer is not it because I don't have any margin above the footer. So let me show you a really neat way to deal with nested elements when you're using CSS Inspect. Now I want to make a point of saying this because I'm betting that a few of you that are watching this exercise with me and doing it along with me, have sort of disabled CSS Inspect sort of unwittingly.
If you ever click on an element, essentially what Dreamweaver does is it establishes focus on that element and it turns Inspect off. So as I begin to hover around anymore, I'm not seeing it any more. If that happens to you, don't panic it's not a big deal. All you have to do is get right back up to Inspect, turn it back on again and you're back in business. So if I hover over a nested element like this photograph for example, I am seeing the contents of the photographs. But I can also start using my Arrow keys. If I hit my left Arrow key I go back outward to the parent that it sits inside of, in this case it's a div with class of artwork and I can use my Tag Selector to see that.
If I hit my left Arrow one more time it goes further up the tree to its parent. Now look, see this is the article with an ideal spotlight and sort of everything sitting inside of it I can see that it has a margin that's pushing down a little bit and it's actually touching the footer. And if you hit your right Arrow key you'll go back down the tree. If I had to guess out of these elements, I would say that last one is causing the problem. So now by using CSS Inspect, we get a nice visual overview of all the Box Model properties the elements have applied to them.
And it's really easy for us to troubleshoot and find out who is causing issues within our layout. So now that we know the elements that are causing the problems, correcting them will actually be pretty easy. Now I know that often it seems like people kind of hype features, they hype it more than maybe it deserves. But I am being incredibly honest with you here when I say that I view the CSS Inspect feature as an invaluable part of my style and workflow. If you've ever used Firebug, Opera's Dragonfly or Webkit Inspector you know they have a similar feature to CSS Inspect.
However, when Dreamweaver's CSS Inspect is combined with another feature which is the Code Navigator they become an indispensable tool for inspecting and troubleshooting your styles. So in the next movie, I am going to show you the Code Navigator and how it works with CSS Inspect.
Get unlimited access to all courses for just $25/month.Become a member
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.