Viewers: in countries Watching now:
There's a little bit of a problem with our application and it's sort of hard to debug. The problem is with CSS layering and CSS layering is controlled by the z index attribute. So, if I grab any one of these and I drag them over and I click on any other one you'll see that this new one is now underneath this one. And really, every element that I pick up should be on top of the previous element. Just in case I want to rearrange things at one point. So, this is sort of a small problem, but it's something we need to deal with. The reason that's happening is, if we Inspect Element right here is, because every one of these elements originally has a z-index of 5.
As soon as we start dragging them they get a Z index of 10. But because I drag these two elements, they both have the same Z index. And that's a problem because the one I dragged first is going to be on top of the one I dragged second. So in order to make sure our objects are always on top, we're going to have to write a function and fix that. So I'm going to create a function up here called reset Z. So I'll say function. And we'll call it reset z. And this function is just going to look for every element that is an image in the dom.
So, I'll sign that to a variable called elements and I'll use query selector. This time I'm going to use query selector all. Because that's going to return an array of all the elements matching whatever I have in here. So I'm going to look for all the IMG elements and then I'll create a for loop and the way that this works is I want to go through all the elements. And I want to set this style of all the elements that I get returned by that and grab the z index of every one of those elements and set them back to 5.
So this is just going to take every single image and reset them all to have an index of 5. And so what I want to do is, right before I set the z index of the element that I clicked on. I want to call this function, to make sure that every other element has a z index of 5. You may want to note that whenever I do any CSS property, I don't use the name of the property right here when I'm using this method of calling it. So instead of using z-index, I have to use camel casing, so the Index here is capitalized.
So let me save that, and then I'm going to go over here and refresh, and I'm going to grab this. And then I'm going to drag this one, and this one should be on top when I do it. So let me just go ahead and right click on inspect element. And sure enough, this one right now has an index of ten because I just grabbed it. And then when I click on this one keep your eye down on the Elements panel. When I grab this one, now that one should have the z-index of 10. So let's see, this one now, get the z-index of 10, you can see it right here.
And when I click on this one, that one's going to go to the top. And now that one has a z-index of 10. So now everything is layered properly. It's not a really big problem, but it can really get annoying with working with some elements on the page. Once you're done with your main code, it's a good idea to look for small issues like this. That will improve the user experience of your application.
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.