Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Now to rearrange our photography, we are going to go into our photo lineup statements and make some changes. So let's scroll down in our script here. The first thing we are going to do is on the line where we take the marquee photos and append the image, which is where we actually are injecting image items into that particular div, we want to take off this style attribute that's inside up here. So let's select style=, select this all the way out, even including the concatenation of the variable photo position, and let's delete that from the statement here. Next, we want to take this next line here with the css, with the width setting on the outermost container, and delete that altogether.
So now that we those two changes in place, let's hit a few line returns. So now what we are going to do is write two statements that are going to actually clone the first photo and the last photo and then rearrange their position within the photo lineup. So let's start with the last photo first. Let's start with the dollar sign and parentheses, tick marks inside for a string literal. We are going to type .marquee_photos img, and then a colon, last-child.
Outside of the parentheses, we are going to type .clone, beginning and ending parentheses. That's going to duplicate that item. Then we are going to type .insertBefore beginning and ending parentheses, then a semicolon. Inside of the parentheses for insertBefore, two tick marks for strings literal, .marquee_photos img: first-child.
So what this is going to do is search for all of the images inside of marquee photos, find the very last item, duplicate it, and then insert the duplicate before the first image item in the photo marquee's div. Let's add another line. Now what we want to do is take the first photo and put it to the end, although that's no longer the first photo anymore because this statement here took the last photo and made it first. So now we need to target the second photo and clone that and make that the last item in the list.
So we are going to do that by starting with the dollar sign and parentheses, tick marks inside again for string literal, marquee_photos img: and then nth for nth child, so nth-child. Then we are going to do put beginning and ending parentheses and then the number 2. Outside of the main parentheses for our original statement, we are going to type .clone, beginning and ending parentheses, then .insertAfter, beginning and ending parentheses, semicolon.
Inside of the parentheses, two tick marks for a string literal. Then we are going to type .marquee_photos img: last-child. So now what this script is going to do is look for the second image inside of marquee photos, clone that, and then insert it after the very last image in our list. So this statement here on line 47 is going to give us our last item as the first, so now we are going to have five photos, and then this one is going to take the second one, duplicate it, and add it to the end, which is going to give us our sixth photo.
So the original four photos we are getting from the lineup statements up here are now getting two additional photos added and having them placed on either end of our photo lineup. So now that we've manipulated our photo lineup in a way that we looked that in the introduction video, in the next movie, we will work on positioning all of these six photos in that photo lineup.
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.
Your file was successfully uploaded.