Make Divs Wrap Onto Separate Lines
Hey everyone this video, you'll notice that we have all these testimonials here, They're here because I want to show you how flex wrap works. Okay, so we've got these guys all in one parent tag okay? They're not an individual rows. Okay? They're all in their own one tag and there's a cool little feature called text wrap or at least flicks rep that will break them onto their own lines. Yeah, so let's learn how to do that and add some testimonials. Alright, in my mock up of mocked up, three different sorry, four different testimonials here. And what I'd like to do is I like this site to kind of just grow as I keep adding testimonials to get longer and longer. So instead of making a row, okay, So I could make a div tag like a parent and put these two in it and split them using flex box, okay? Or and then do a second one. Trouble with that though is that I have to make a parent for every single one. And what I want to do is I want to show you the flex box attribute called text wrap. It mea...
ns we're going to make one giant or one parent for them all to go inside of and what we're going to say is guys just wrap on the next line is that if there's too many of you and you don't fit, go to the next line because by default what it tries to do, like these fellas here just tries to squeeze them all on the same line now, it's going to take us a little while to build this up. So if you just want to cut to the shortcut sheet in your exercise files, under flex box, this is the attribute here. So you can kind of see what it's doing there. It's going to to the parent tag. Just add that rap condition. Alright, But I want you to, if you're working along with me, okay, I want you to let's go through the rest of this tutorial because I want to have a few bits and pieces because there's some things later on in this course, if you're thinking I'll just skip this one, it's gonna come back around because I want to do certain classes and all sorts of other fun stuff later on. Cool, so where to add them? It gets confusing down here, Right? And you're like, where is all this? And I find just clicking in them, you can see it's kind of married up his buddy up the top there. Okay, so cards end there after cards finish, I want my testimonials to start. I'm going to put a nice big break in it to make it easier for everyone, mainly for me. Okay, so I'm gonna create a class cord test ceremonials close enough for me. Okay, and inside of there, I'm going to make how many? We need three of them. So I'm gonna create all the classes now, there's one going to, I'm going to call it test box T box. Okay. And unlike our cards where we've got card 12 and three because these are exactly the same. Okay, All the way along, I'm just gonna use the same class to control them all. Cool. Inside of these tee boxes are going to be some texts that I've got in your project to folder. Okay, look for a project to text and I've got my testimonials, I'll show you this testimonial generator dot com. I do not use this by myself. Okay. But I was looking for something for this class and I just needed to go through. Okay. And I found testimonial generator dot com. You put in your projects servis dans back massager? Nobody wants one of those. Okay. Ah and there you go, generate since I've invested in Daniel's Back massage, I've made over, Wow, profit. Okay. Of I'd be lost without that, you get the idea right, You can generate all of these things. I did, I did for these ones, but I don't for my own particular ones. Okay, So I put in raw cycles and what I'd like to do is I'd like them, I'd like this, so the name separated from the body copy into two separate p tags. I'm gonna copy this first bit. Okay. And I'm going to go into here and I'm gonna put in the P tag and I'm going to paste that in. Okay. And I'm going to tidy it up, that's the kind of guy I am. Here we go. Okay. And we'll do another P tag with, I could just make up the name. Right, okay, another P tag and I'm gonna put this one in there. All right, So I want that for three of them. So I'm just gonna duplicate them copy paste paste. They're all getting my tabs all getting messed up. Do you remember what we did earlier? I'm gonna select where is all of this. I'm gonna right click it and I'm going to go to format selection. You see the shortcut there if you're finding, you know, you want to do it all the time and now it's nice and spaced. Okay. It's gonna switch out the text. I'll get the editor to speed it up Now. The editors, Jason. Thanks Jason. And for some reason, and we decided we needed three. Clearly we needed four. Okay, uh there we go, paste them in and within us one in and I'll see you in a second. All right, you're back. What you might have noticed is when I did my cleanup, cleaning up my code. Did some weird stuff by putting this in there. I'm not sure why. Maybe it's the apostrophe. I'm not sure. I didn't really clean it up. I got my tabs, right, but did some weird stuff with the P tag. Remember if yours is flowing off the page. Get a view and toggle the word, wrap. Okay, if it's going all the way off there might be how you like it. I'm I don't alright so I've got my four things in. Let's have a look at it in my page. Is that the one, is that the one there? It is there? Okay, so I've got these four testimonials. I haven't styled them at all. So let's go and do that. So let's go. I'll style the tee box first. Okay because they're the ones that have like the width and height so dot T box, I'm going to do a couple of things to it. I want to give it a width. Okay In this case I'm going to use percentages and I'm going to do, I already tested this. Okay. Um I'm going to make it 37% to have a little look. Okay and remember actually that's a little small. Yeah, good work down testing it. So that's that they're perfect and I would like to Put some padding around it. Okay so padding all the way around. I'll do 50 pixels and I want to get them up on the same line. Actually put the line around the outside first just so that we can get that done. So we do border, I'll spell it wrong for like the millionth time border and we are going to do the same as we did for the buttons it's going to have a width of one. It's going to be a solid border, it's going to be white, let's have a little look and how close is that? That's pretty good. Okay now I want to get them up on their own line. It's never going to happen at the moment because we've got ours a little bit big. You can kind of see I made it be 47%. Okay but it's way past that, it's way past 50. Why is that? You know why? Because we added the padding. Remember the padding added to the total width? And you're like okay so I could that's why I had 37 in my head because 37 plus my padding it makes it less than half or is it less than half. And that was just being sneaky trick and but we don't want to do that. We want to be all official. Do you remember how to do it? Okay we do it to the box or the wrapper box. I think we can do it too. I'm not even sure my mind's gone blank. Let's check it at our testimonials. Testimonials. Okay and let's remember. It was remember. Border box border border box. No it's box size box sizing. Border box. There you go. No you have to actually do it to the things themselves. Of course you do. That makes sense. There you go. Okay, so by doing that. That minuses off that and we're good to go. All right. Next thing we want to do is get them up on the same line. Okay how do we do that? I want you to pause it and just have a little think it's not an exam. It's kind of like a pop quiz. All right. What we did before. Okay, is remember we set the display to flex. Okay. And by default they'll all try and squeeze on the same line, which is cool. The next thing we're gonna look at is the bit we have, Well, we didn't have mentioned. I totally pointed at it. Okay from your flex box, um cheat sheet. Okay from the exercise files and we set the flex wrap to rap because that's what we want to do. Okay, let's have a look. Let's go to here. Let's set the flicks rep to wrap. Here we go. See if it works. Nice, awesome. Huh? Now I want to separate them up. I could start adding padding between them. I could do to be a little bit hard. Okay, do you remember what the class we add from flex box just to separate them all out. We did it for this one. You can cheat and go and check that one. Okay, where is my cards cards? There it is up here. Okay. Remember this one justify content space between All right cards, you know like he was just stalling because he couldn't remember a little bit, but that's what it is justified content space between. Okay. And it should separate them all out. Now I want to add a little bit of margin to the top. Okay, so of these little tee boxes here, I'm going to say imagine martin margin, we'll do top And how much we will do. 50 pixels. Here we go. There's a little borders. Okay. We've got this weird thing going on with the height here. Okay. With our gradient going random in the background. Let's fix that. And what's controlling him the top here. So we added this before to fix the problem with our website was too small. Okay, and it's made that initial view. Okay, 100%. Which kind of gets us down to the bottom of my screen now, yours might not have this problem because your screen might be smaller or bigger. Okay, but we don't need the height to be 100% anymore. There you go there because my website is nice and long. I do need some padding underneath of these guys are actually, where do you add the padding now? Okay, we don't have a footer in this site. Weirdly, I just didn't design one with one, so I don't have to have one. So where should I do it? Mm Well, I might put it at the bottom of the testimonials. I'm reluctant to add padding to the bottom of the body only because I'm gun shy. Like, um, messing with the body tag can do weird stuff, especially if you're working with things like Bootstrap flex box. They all, they all got their mitts in for wanting to do stuff with body Gabe. I'm going to just be super careful and just use the one that I made. I know that they're not going to mess with it. Okay. And I'm going to say margin bottom And I'm going to say 50, maybe hundreds. Double it up. Let's have a look. That's my mock up. Mm hmm. There we go. Some padding at the bottom or at least margin at the bottom. Alright. So we learned what flex wrap does. So it means that these guys are all four guys all in one box. And the cool thing about it is that if I made these guys smaller or I added more of them. Okay, so let's go copy. I'm going to add a few more paste paste paste. Making loads more. And the cool thing about them is check it out. They can just keep wrapping onto the next line. All right. I just, I don't want all those guys go away. Nice and clean back to where we started. Except you you over there like the mic and we're done. All right. I will see you in the next video