PSD to HTML 4.6) jQuery Navigation
Transcription of PSD to HTML 4.6) jQuery Navigation
hello and welcome back to the PSD to HTML responsive portfolio build in thislesson we’re going to finish up some of our responsive here by changing the way our weather behaves whenever we decide so once we get to that same break point here where we’re reaching 640 pixels and things are changing their arrangement were also going to change the footer so that we no longer have three columns and said there’s gonna be stacked on top of each other and that’s pretty simple to do so I’m gonna jump into our CSS and everything into the site 24 folder now and then down here below everything else but still inside that media query notice were still inside the closing curly bracket for that media query we’re gonna point to our columns and remember our columns four-footer have a class of Cohl hyphen 15 and third and what we’re gonna do is simply set or flute to none so that they’ll no longer be floating to the left and then we’ll set our with for those columns to 100% safe that go back to our page in refresh it and now our items are all stacked on top of each other instead of lined up in three columns and just to double check will go all the way to the bottom make sure our copyright still looks fine and it does and we are now almost done with our responsive design the last thing we need to do is we need to tackle our menu items here and and what we need to do is actually use a little bit of G query don’t let that frighten you if you never use Javascript or jQuery before it’s just a couple of lines of code that we’re going to use to get that mean you to work so once it disappears we want to click on that to see our menu dropdowns that we can click to go to another page so we’re going to add that jQuery to our index HTML file but first we actually leave to jQuery otherwise we won’t be able to use it so we’re gonna go back up to the head of our document then down here just below are still she we’re gonna link to jQuery and we’re gonna do that by going to grow and expand your browser at a little bit for new code that jQuery dot com and we want to link using the jQuery CDN so scroll down and see different versions of decreed that we can use but you’ll notice that with two point Xie anything less than ie9 is not supported yet so we’re going to jump down to this one here and we can click on the magnifying version to view it or we can just right click on the minute 5 version and click on copy the address they were going to use that link address in our HTML so just below are just before closing head tag I’m gonna create a script tag and we’re gonna set the source for that equal to that link we just copied soco done jcrew.com / jQuery hyphen one-dot 11 20 demanded Jes there might be a more recent version by the time you watch this video series or there might not be a min opener closing script tag after it then all the code that I’m going to use for our menu I’m gonna put down here just before the closing body tags will put a few line breaks in there and then somewhere between the closing foot attack in the closing by DTAC we’re gonna put a script tag and we’re going to put her closing script tech so when you’re using jQuery the first thing we want to do is we want to wait till the entire page is finished loading before we run our code in the way we do that I’m not gonna go into detail on how this works but we’re going to take a dollar sign the set of parentheses and inside the parentheses we’re going to create a function so take function another set of opening and closing parenthesis and opening curly bracket then we’ll skip a couple ends are closing curly bracket and a semicolon at the end of that so we have this function that is called after the entire page is finished loading so inside that function we want to point to our navigation list remember it has a class of now hyphen list and we can actually use that CSS selector in jQuery to point to it but we don’t want to point to it the way you would point to it first of all as you type a dollar sign in an inside parentheses and inside single quotes who would tighten have died in that I should list so we can point to that particular item that navigation list in jQuery using that CSS selector a.net hyphen list however referring to it this way can be a little taxing on the system so what I’m gonna do is to avoid referring to it this way over and over again number to create a variable called dollar sign now and then we’ll just set it equal to this value so anytime we want to refer to that and have list we can now refer to it using this dollar sign now have variable so when I want to do is when I click on that menu icon that we created that menu I kind of remember has a class of menu hyphen icon whenever we click on that I want our navigation to open up so we’ll skip a couple lines and we’re gonna do that is we’re going to point to that menu icon first of all you’re gonna say . menu hyphen icon and again that’s contained inside quotation marks inside parentheses just after that dollar sign no space after the dollar sign or it’s not gonna work and then in order to create a click event just after the closing practices were gonna take . click in the imprint the seas were in a type function open close parenthesis again open curly bracket give a couple lines in the new clothes curly bracket and then open a semicolon after that close curly bracket then inside this function this click function we’re going to take the code that we want to occur whenever we click on that menu icon will win I click on that menu icon I want this navigation to toggle open and close to basically and there’s a great function in jQuery for that called slide toggle certain points to that and have lists class which is that drop down menu that we have now and again we can refer to it now using dollar sign now and we’re gonna say dollar sign that . slide toggle with a capital T insensitive function we need to include open and close parenthesis and a semicolon to in their statement so let’s see if that works see that jump back into our page and refreshes and then will resize it until we can see our menu icon near now when we click on it it expands open and click on it again to collapse the problem mill is the firing resize my browser that menu icon disappears but my menu doesn’t come back so we’re going to create some orgy query to make that happen so we’re still inside this document ready function dysfunction that isn’t going to run until everything has loaded just inside that we’re gonna skip a couple lines and make sure you pay attention to the placement of all these closing curly brackets and parentheses and everything because things might break if you don’t so if you’re having some problems getting your code to work right then double check to make sure that all your print the seasoned curly brackets are in the right place so after the closing early break in print this is for this click function but before the closing curly bracket for this document ready function we’re going to create another function what we’re gonna do is working to create a function that that detects twin where resizing the window and if the windows which is greater than six hundred and forty or greater than or equal to 640 pixels than we want that navigation to show up we want this nav list menu to show up we went to set its display to the similar blocker whatever it is well there’s a function in jQuery Culture Show and another one called hide that allows us to do that so the way this is going to happen is this time we have dollar sign in parentheses but instead of a CSS selector we’re just gonna type window which will points to the current browser window and then after the parenthesis wanna take . resize and inside parentheses something that we’ve done already a couple of times function open close parenthesis open and close curly brackets and then a semicolon after that closing princesses at the end so inside this function we’re going to basically test to see if the width of the window is greater than or equal to six hundred and forty in if it is then we want to see our menu we wanted to show up in that rain out bar that light green fr the top of the way we do that as we type if and when using an if statement will then type parentheses and put our condition inside the Sprint disease and then if it ends up being true we’ll put everything we want to happen inside these curly brackets here so are conditional here is word testing to see what the size of the window is as we’re resizing it that’s what this resize function does all of this code inside this recites function is going to run over and over again as long as we’re resizing it so we’re gonna test to see if the width of the windows will point to window . winds did with is a function there it’s not a property to function so we have print the season there as well we’re gonna see if that’s equal to actually received its greater than or equal to six hundred and forty so we put a little space in here so you can see this a little bit better so we’re pointing to the window again here and we’re checking the width of the window if the whip through that window is greater than or equal to six hundred and forty then what do we want to happen we want that navigation menu to show up so we’re gonna say dollar sign now . show in that show method is a jQuery method then we can say else in other words if our windows with is less than 640 we want to hide it so . now I’m sorry dollar sign that . wide open close parenthesis semicolon to interstate and that’s all the jQuery you need now if you can’t get this to work right you might go back and watch this video of couple of times to try to understand it if you’ve never used jQuery before and he still can’t get it to work right it might behoove you just to come into the project files and copy the script and paste it into your own file but let’s save that and see if it works will jump back into our code refresh the page and we can see our menu at first but that wasn’t a problem before it wasn’t a problem until we shrink it down and then resize that backups let’s make it smaller again let’s expand it out and contracted and then let’s make it larger again and hopefully the menu text will show up again and it does he go smaller and it still works and now we are finally done with our responsive portfolio site thank you for watching and I’ll see you in the next video
PSD to HTML 4.6) jQuery Navigation
Reviewed by Tayyab Saqlain Zakki
on
00:04
Rating:
Reviewed by Tayyab Saqlain Zakki
on
00:04
Rating:

No comments: