Layout & Design

Practice: Designing Fluid Layouts in Framer (Fundamentals Lesson 24)

Practice: Designing Fluid Layouts in Framer (Fundamentals Lesson 24)

Practice: Designing Fluid Layouts in Framer (Fundamentals Lesson 24)

Joseph

·

22:31

·

33K views

·

About this lesson

Toward the beginning of this course, we looked at how different positioning and sizing modes change how layers behave when parent frames, or even the browser window, change size

In this lesson we’re going to put it all together go over some best practices for creating fluid layouts in Framer

https://www.youtube.com/watch?v=OKnkLP4pw4Q&t=0s Intro

https://www.youtube.com/watch?v=OKnkLP4pw4Q&t=4s Why responsive design matters

https://www.youtube.com/watch?v=OKnkLP4pw4Q&t=15s Scaling layouts for all devices

https://www.youtube.com/watch?v=OKnkLP4pw4Q&t=36s Ensuring consistent experiences across viewports

https://www.youtube.com/watch?v=OKnkLP4pw4Q&t=53s The SEO benefits of responsive design

https://www.youtube.com/watch?v=OKnkLP4pw4Q&t=63s Designing responsively in Framer

https://www.youtube.com/watch?v=OKnkLP4pw4Q&t=76s Wrap up

🌞 Start for free: https://framer.link/yt

📚 Learn more at: https://framer.link/yt-academy

💎 Join the Community: https://framer.link/yt-community

🎉 Follow on X: https://framer.link/yt-x

0:00Toward the beginning of this course, we0:01looked at how different positioning and0:03sizing modes change how layers behave0:05when parent frames or even the browser0:08window change size. In this lesson,0:11we're going to put it all together and0:13go over some best practices for creating0:15fluid layouts in0:17[Music]0:19Frame. In this lesson, we're going to be0:22workshopping this project file, applying0:24what we've learned in the previous0:26lessons. We're not going to cover0:27anything completely new. So, if anything0:30is super confusing, you'll want to refer0:32back to the corresponding lesson where0:34we covered that particular topic in0:36depth. But if you're up to speed on what0:38we've covered so far, then this will be0:40a great opportunity to see how things0:41come together in practice. Feel free to0:45grab the remix link and follow along.0:46I'll put the link in the description0:48below here on framer.com/academy.0:52Before we jump into my project file0:53here, I want to take a bird's eye look0:55at a general structure for our pages0:58that set us up for success. These aren't1:00rules or requirements, but you'll1:02probably find this structure to be a1:04helpful framework for a lot of the pages1:06you build. As always, the top level of1:09our page structure is going to be the1:11breakpoint. In this lesson, we'll focus1:13on the desktop breakpoint, but in the1:15next lesson, we'll look at how multiple1:17breakpoints work. Our breakpoints are1:19going to be a fixed width, but the1:22height will fit the content of the page.1:24I also don't like to add padding to the1:26sides of my breakpoint cuz it'll push1:28absolutely everything inward and get in1:30the way if we want to do a section that1:32fills the entire width. But within the1:35breakpoint frame, we'll create frames1:37called sections. These will fill the1:40width of the breakpoint and stack one1:42after the other containing the main1:44sections of content for our page. Think1:46along the lines of a hero section1:47followed by a feature section followed1:50by a testimonial section. So on and so1:53forth. You get the idea. Within sections1:55is where I like to add my side padding1:57to keep content from bumping right up1:59against the side of the browser. But2:01depending on what you're trying to do,2:02you can at least decide whether or not2:04to add padding on a section bysection2:06basis. And finally, since my sections2:09are going to fill the width of the2:10entire browser, no matter how wide2:12things get, I'll often create another2:14nested frame that I like to call a2:16container, where I can add a max width2:18to prevent everything inside of it from2:20getting impractically wide. Sometimes2:23folks will add padding to their2:24container frames rather than their2:26section frames, and that's fine, too.2:29Again, these aren't rigid rules. This is2:31just a general structure you'll see2:33often used by myself and by others in2:36their framer sites and also in2:38templates. Now, without further ado,2:40let's jump into the project file and see2:42what we're working with. And we're doing2:44this live, so bear with me. On this page2:47that we're going to be focusing on,2:48we've got a lot of layers that are set2:50to absolute positioning, which means if2:53we preview this, I'm going to click on2:55the preview window here. And I'm going2:57to do this so many times that you'll see2:58me using the keyboard shortcut more3:00often than not. And that shortcut is3:02command P on a Mac or controlP on a PC.3:05That'll toggle you in and out of this3:07preview mode where we can check to see3:10if we're doing a good job making our3:12layers responsive, making sure that they3:14flex fluidly here. But in its current3:16state, if I make the viewport more3:18narrow here, you can see that these3:20layers aren't flexing at all. The image3:22isn't getting smaller. The nav is3:24getting cut off. The text eventually3:25gets cut off. It's really quite a mess.3:28The footer and all. So, absolutely3:31everything is causing a problem on this3:34page. And we're going to fix absolutely3:36everything. We're going to start from3:38the top. Hierarchically speaking, we're3:40going to start with the properties of3:41the breakpoint and then we're going to3:42go section by section. But to get the3:44properties of the breakpoint dialed in,3:46I want to do so within a layout3:48template. So that way I can apply that3:50to all of my pages as this site3:52continues to grow. So let's start with3:55an element that's going to belong on3:57every page, like this navbar. I'm going3:59to rightclick on this and I'm going to4:01choose create layout template. And I'm4:03just going to name this main, but you4:05can really name it whatever you want.4:07I'll click create. And then here we are4:09within the layout template where we have4:12our navbar because that's the layer that4:14I created the layout template from. And4:17then we've got the placeholder which is4:18where all the content for the page is4:20going to go. And if I zoom out you can4:22see these are the only two things that4:23are on the page. But really what we want4:25to focus on first are the properties of4:27the breakpoint itself. I don't4:30necessarily want a gap to be enforced4:32between every single section here. So4:35I'm actually going to get rid of the4:37gap. We'll manage our vertical rhythm4:39using padding within the sections. Now,4:42again, most of what you see is going to4:44be opinionated. These aren't rules. You4:47can approach this differently if you4:48want to, but I'm going to get rid of the4:49gap here. And before I forget, I'm going4:51to go back to our homepage here, and I'm4:54going to grab this footer and press4:56command X to cut. And then I'm going to4:58go to the assets panel, go back into our5:01main template here, and I'm going to hit5:03commandV to paste that footer in. I just5:06want to make sure that I have all of my5:07global elements here within the template5:09before I forget any of them. So, we've5:11got our navbar, we've got our footer,5:13and again, if we go to the preview5:15window and we take a look at this, we5:17still have all the same problems that we5:19had before. Nothing is flexing fluidly5:23with the viewport. So, let's start5:25fixing these things one thing at a time.5:27I'm going to start with the navbar here.5:29Now, it doesn't really matter what order5:31you do these things in, but for the5:33navbar, my approach is going to be to5:35start with the child layers, make sure5:36they're all good, and then work my way5:38up the hierarchy to the top. So,5:41starting with our links here, if I5:43select this frame that's containing all5:45these links, you can actually tell by5:47the icon here on the layers panel that5:49this is a regular frame that doesn't5:50have a stack layout. But because it's5:52full of children that are distributed5:55horizontally with even gaps, I'm going5:57to turn that into a stack. So, I'm just5:58going to click the plus sign here to add6:00a layout just so if I add more nav items6:03later or remove them, they stay nicely6:05distributed horizontally. The logo on6:08the left side is not a stack, but that's6:10okay. It's just containing some layers6:12that are absolutely positioned. And6:14since the logo is never going to change6:16size, it's always going to remain that6:17same size. It's really not going to6:20cause any problems just to leave that6:21alone the way it is. So, I'm leaving the6:23logo alone. But the parent frame, the6:25main parent frame, the nav bar, the6:28whole bar, this is where most of the6:30work is to be done. So the first thing I6:33want to do here is I want to make sure6:35that the width is set to fill the width6:38of its parent, which is the breakpoint6:40itself, which means the viewport or the6:42browser window. So with this set to6:44fill, we're solving a major major6:46problem here. The thing is simply6:49setting this to fill doesn't solve the6:51problem of the position of its child6:53layers. So you can see here that uh6:56we've still got problems. So let's go6:58back and fix those problems. And the7:00problem is that its immediate children,7:01this frame with the links and the logo7:04are just floating around using absolute7:06positioning. So I'm going to again, you7:08might have guessed it, I'm going to add7:10a layout to our navbar. And that's going7:13to put the parent frame in charge of the7:15position of the children. And you can7:17see that their position has already7:19changed. They collapsed inward. And the7:21reason for that is we've got a7:22horizontal stack that is set to7:24distribute the layers in the center. So7:27they're starting in the center and the7:30space between them is determined by this7:31gap here. What we really want is to7:34instead create space between them. So7:37when you choose space between, you're7:39saying evenly distribute the available7:41space to spread these layers out7:43essentially as far as they can go. So7:45they've gone all the way to the edge.7:47They've hit the edge. And the only7:49reason they're not hitting the top and7:50bottom edge is because we have a fixed7:53height of 80. But let's actually change7:54that. Let's change that to fit the7:57content. So you could see now that the7:59width of this bar is going all the way8:01across the breakpoint and the height of8:03it is clamping down to those child8:06layers. So now it's become more obvious8:07that the issue is just padding. So I'm8:10just going to add 20 pixels of padding8:12here. And there we go. Problem solved.8:14Now these things are being pushed all8:16the way out, but they're also being8:17nestled nicely inward with 20 pixels of8:20padding. Now let's preview this8:22again. Cool. That is more like it. Now8:26you'll notice that this kind of gets8:27infinitely wide. And if someone is on a8:29giant display, they might not even see8:32the nav links. They might be so far off8:34to the right. They might not see the8:35logo. it'll be so far off to the left.8:37So, let's actually enforce a max width8:40on here. I'm going to click to add,8:42choose max width, and we don't want a8:45relative width. We want to get to a8:47specific width where we say don't get8:49any bigger than this. And I want that8:50width to be 1,200. The break point's8:531200. We're looking at it currently at8:551200. And that looks pretty good. So,8:57let's just say it stops when it gets8:59there. And let's preview this again. So9:02sure enough, when the viewport gets9:03wider, the navbar doesn't get wider. But9:06when the viewport gets smaller, then9:07that max sizing is no longer getting9:09enforced and that fill sizing is getting9:11enforced instead. Perfect. So now let's9:14fix this footer. It's going to be very,9:16very similar. We've got this stuff on9:18the left and we've got this stuff on the9:20right. But let's go through the same9:22motions here. I'm going to select the9:24parent frame. I'm going to start from9:25the top and work our way down this time.9:27And with the parent frame for the footer9:28selected, if I add a layout and do the9:31very same thing. I'm going to set the9:33distribute to space between. Now, all of9:36these things are being distributed9:38evenly. All of that available space is9:41being split between the column on the9:43left and all the other columns for the9:45links. But that's not really how we had9:47it laid out originally. The reason for9:49this is that if you look at the9:51immediate children of the footer, each9:53one of these is an immediate child. So9:55the space between is being distributed9:58between each and every one of these.10:00What I can do is select these link10:02columns and wrap them in their own10:04frame. And I want that frame to clamp10:06down on these things. I don't want it to10:08be any wider or taller than it needs to10:11be. So rather than creating a frame and10:14adding a stack layout and then setting10:16the width and the height to fit, I can10:18just press shift A on the keyboard and10:20that'll automatically wrap my selection10:22in a frame. add a stack layout and it'll10:26set the width and the height to fit all10:28in one step. Now, all I need to worry10:30about is the gap between them. So, I10:32think that gap originally was around 60.10:35And I want these all to be nicely10:36aligned at their top edge. So, we're10:39getting warmer here. Now, I'll go back10:41to the footer frame. I'll make sure that10:42the width is set to fill so that it gets10:46wider as the browser window gets wider.10:48And the height, I'm going to do the same10:49thing I did with the nav. And I'm gonna10:51have this clamp down and fit the content10:55and then fix the spacing around it using10:57padding. So I'm just going to add a10:59uniform 80 pixels of padding. And that11:01gets us back to pretty much exactly11:04where the original design was. If not,11:06we'd have some fiddling to do, but 8011:08pixels happens to look okay. So I'm11:10going to stick with that again. I'll hit11:12command P to preview. And let's take a11:14look. There we go. So now things are11:17getting smaller when they can and things11:19are getting larger when they can. And11:21we've got that max width being enforced11:23on our navbar, but we don't have that11:24being enforced on our footer. And that's11:27okay. I'm I'm actually cool with that.11:28I'm going to leave that as is. If11:31someone navigates all the way down to11:32the footer, they're probably visually11:34scouring things. So I would say it's a11:36less sensitive situation if they have to11:38look a little further to the left or a11:40little further to the right. Cool. So11:42we'll go back and we'll go to the11:44homepage. And I'm going to press command11:461 or control 1 on a PC to zoom all the11:50way out and fit everything into view.11:51And you can see that our layout has11:54gotten kind of crunched. And what's11:56going on here is that now that we have a11:58layout template applied, our desktop12:00breakpoint has become a stack. That12:03happens automatically. That comes with12:05the territory. The breakpoint becomes a12:07stack and all of its immediate child12:09layers are now flowing from top to12:11bottom. And because I got rid of the gap12:13within the breakpoint properties,12:15there's no gap between them. They're all12:17kind of like sandwiched and scrunched12:18together, which is fine. We have a12:21little bit of work to do, but that's12:22totally fine. I'm going to start by12:24recreating that structure that we talked12:26about at the very beginning of this12:28lesson where I have sections and then12:30within sections, I have containers12:32containing the content. And for our12:34first section, I'm going to group up all12:35of our hero content. So, I'm going to12:37select this image, the text all the way12:40up to the tag. I'm going to rightclick12:42and I'm going to choose add stack. And12:45wrapping your selection in a frame this12:46way automatically sets the height to fit12:49and the width to fill, which is exactly12:51what we want for a section. And to keep12:53things clean, I'm going to come over12:54here to the layers list. I'm going to12:56double click and I'm going to name this12:58section section dash13:02hero. And this definitely needs some13:04padding around it. I want more padding13:07on the top than I want on the sides, I13:09think. But let's start with 40 pixels13:11all around. And you can see we already13:14have a little problem where our drop13:16shadow is being clipped by the section13:18frame. And that's because the section13:20frame has the overflow set to hidden.13:23So, we can either switch this to visible13:25or we can just add a bit more padding13:27and then it won't be a problem in the13:28first place. So, let's actually do that13:30cuz I know I want more space above and13:32below this section. I want just a bit13:34more breathing room. So, I'm going to13:36split apart our padding. And for our top13:38padding, I'm going to go 80. And I'm13:40going to do the same for the bottom.13:42Going to go 80. So, I think that looks a13:45little more natural. We've got a little13:46more space up here. Pushing the content13:48below it down. So, I think I'm happy13:50with that. 80 top and bottom, 40 on the13:53sides. And the 40 on the sides. If we go13:56and I'll press command P to preview13:57this. The 40 on the sides isn't really14:00presenting itself in any which way. And14:02the reason for that is we've got a bunch14:04of layers that have their width set to14:06fixed. So that 40 pixels of side padding14:09can't really push on anything. So let's14:12fix that. I'm going to start with this14:13image cuz that's the most glaring issue14:15cuz it's the widest thing. And I'm going14:18to add a max width. I'm happy with this14:21fixed size. I like where it starts out.14:24But I want to add a max width that does14:27not allow it to get any larger than 100%14:30of its parent. So that's it. Let's14:33preview this again and see what that14:35looks like. And you can see this is14:37already sort of fixing the issue. You14:40can see that the frame is now respecting14:43that padding. So not loving it cuz the14:46image is getting cut off. So what I want14:49to make sure to do is click the lock14:50between the height and the width to lock14:52the proportions of this image so that it14:54gets less tall as it gets less wide. And14:56there we go. That did the trick. But our14:59text up here at the top, our text is15:01definitely still a problem. So, let's15:04see if we can fix that. I mentioned15:06earlier that within a section that can15:08get infinitely wide, I like to create a15:11container for content that I don't want15:13to continue to grow and grow and grow.15:15So, I'm going to do exactly that. I'm15:18going to select the tag, the heading,15:20and the body, and I'm going to wrap15:22those in their own stack. So again, I'm15:24going to use that Mac shortcut of option15:27command return controlal alt enter on a15:29PC. And now I've got my container and15:33I'm just going to rename this. You can15:34call your containers whatever you want.15:36I'm going to name this text lock up. And15:39I'm also going to set my H2 and my body15:42to fill the width, which obviously it's15:45getting too wide. We're going to fix15:46that here in a moment. And to fit the15:48content for the height. So now we can go15:51back to that text lockup container that15:52I created and we can add a max width to15:55that that doesn't allow it to get as15:58wide as it's currently getting. So for16:00that max width, we definitely want it to16:02be fixed. And I think we don't want this16:04to get any wider than 600 pixels. So16:07there we go. That's actually looking16:09good. And the hero now has two direct16:12children. It has the text lockup itself.16:14It has the product image. It has the16:16padding around it. But we probably want16:19to increase this gap here to something16:21more like 40, just so there's a little16:23bit more room between the text lockup16:26and the product image. But before we go16:28any further, let's preview this and see16:29how we're doing. Now, when I make the16:31viewport smaller, we've got our image16:33shrinking. And when this gets smaller16:35than the max width of that container16:37that has the text inside of it, then the16:39fill sizing kicks in and things will16:41automatically reflow and be sure to fill16:44the full width of the viewport. Awesome.16:46That's big progress already. If you're16:48paying super close attention, you may16:50have noticed that I used a fixed width16:52for the image with a relative max width.16:55And I did exactly the opposite for the16:57text container. Don't read into that too17:00much. Both ways are totally fine. I just17:02want to make sure you're aware of both17:04and how they can generate a similar, if17:06not identical effect. Cool. So, last but17:09not least, we just have our features17:11down here. And structurally, I'm going17:13to do the same exact thing I did for our17:15hero section. I'm going to grab this17:16features frame. I'm going to press17:18option command return to wrap this in a17:21stack that is automatically set to fill.17:24It's automatically set to fit the height17:26of the content. I'm just going to rename17:27this section features. And I'll try to17:31be consistent with my padding here and17:34separate the values. And I'll do that17:35same top and bottom padding of 80 and17:38left and right padding of 40 just like17:40the section above. But even still, I17:42kind of don't like that these go wider17:45than the image above. And again, the17:47image above is set to a width of a17:49thousand. So, I'm going to grab the17:51features container that we have here.17:53And that width we can leave on fixed.17:55I'm just going to change that to a,000.17:58So, it's the same width as the image17:59above. And I'm going to add a max width18:01of 100%. So, it'll get squished in18:04nicely. And you can see we've already18:06got a problem here. We've got things18:07that are kind of overlapping all funky.18:10And the reason for that is this features18:12frame again doesn't have a stack layout18:14applied. So these info cards are just18:16kind of floating freely within it using18:18absolute positioning. So for our18:19features, I'm going to add a layout. I'm18:22going to leave this as a stack layout,18:24but we're actually going to come back18:25and revisit this here in a moment. But18:27first, we got to address the issue of18:29these cards not fitting. The most18:31glaring problem is that they're set to a18:33fixed width, and they really need to18:35share the available space. So, I'm going18:36to switch them to fill, which is going18:38to do exactly that. The sibling layers18:41are now going to share the available18:43space. But if we look a little closer,18:45we've still got an issue where text is18:48kind of sticking out of this card here.18:50And the reason for that has something to18:52do with the layout within this component18:55because each one of these cards is an18:57instance of the same component. So, what18:59I'm going to do is I'm going to press19:00the return key to edit this component.19:02And the first thing I'm going to do is19:04just grab this parent frame and wiggle19:05it and see what the child layers do. And19:08it looks like we've got another fixed19:10sizing issue. So, let's select these19:12text boxes, which are obviously the19:14culprits cuz they're sticking out. And19:16let's set the width of them to fill. So,19:18that way if the parent frame gets wider,19:20they get longer. And if the parent frame19:22gets more narrow, they get squashed19:24down. And that should do the trick. Now,19:27if we go back to our homepage, there we19:29go. So now these instances can actually19:31flex. And if I press command P to19:33preview this, we can get a better look19:36at how they flex. Again, we've got a max19:38width, so they're not going to stretch19:39out wider. But if I get more narrow,19:42there we go. They squash down. Now,19:44things do get to a point where they're19:46impractically narrow and the design19:49breaks, which is why we're going to look19:51at break points in the next lesson. But19:53in the meantime, I want to consider how19:55I might futureproof this. And this is19:58kind of open for debate. Right now,20:01we've got our features in a horizontal20:02stack. Now, this works great at desktop20:04sizes. We have plenty of width to occupy20:06with this horizontal stack. And even for20:09mobile, we could just switch the20:10direction to vertical and have these20:12things stack from top to bottom instead20:14of from left to right. But somewhere in20:16between at sort of the tabletish sizes,20:19we're going to have kind of a weird20:21crunch. they're either going to be too20:23wide in one column or it's going to be20:24too narrow for four columns. So, what20:28I'm going to do to futureroof this is20:30instead of using a stack layout, I'm20:31going to use a grid layout. And by20:34setting this to a grid layout, we'll20:35later be able to choose how many rows20:37and columns we want for desktop, for20:39tablet, and for mobile. So, we'll be20:42able to make the ideal choice for each20:44viewport size. In the meantime, you'll20:46notice that we've got some things20:48getting cut off here, and that's because20:50the height of this frame is still set to20:51fixed. I'm going to change that to fit20:54the content instead. There we go. That's20:56much better. And because we're currently20:58working on the desktop breakpoint, I'm21:00going to increase the columns to four21:02and I'm going to reduce the rows to one.21:05Now, we should be in a pretty good21:06place. I'm going to preview this. And21:08there we go. We've got things squashing21:10down real nicely. And if we come down21:13here, we've got our feature squashing21:14down, but there's still one little21:16issue. We've got the bottom of our21:18features. There's supposed to be a learn21:20more button at the bottom of each of21:21these. We've got that getting cut off as21:24these things shrink. And the reason for21:26that is specific to the fact that we21:28turn this into a grid. And if we go into21:31the advanced settings, our grid happens21:33to have a fixed height for each cell.21:35So, we're just going to change that to21:37fit the content instead. Now, one last21:40preview. Let's come down here. And there21:43we go. Now the grid cells are getting21:45taller to make room for all that21:47content. But naturally, if the viewport21:49keeps getting smaller and smaller and21:51smaller, we get to a point where our21:53layout just doesn't make sense anymore.21:55And that is a job for break points,21:58which we're going to tackle in the next21:59lesson. And there you have it. Now22:01you've got a better sense of how basic22:03structures of frames along with all the22:06layout properties at our disposal can22:08come together to create fluid layouts22:10that flex with the browser's viewport.22:13That's it for this one. I'll see you in22:14the next one where we'll take the22:15responsiveness of this layout even22:18further using breakpoints.

Watch on YouTube ↗

More in this topic

8 Framer shortcuts you're probably sleeping on4:19
8 Framer shortcuts you're probably sleeping on
Layout & Design3K views · 2 months ago
Framer Update: Stack Sorting and Bento Grids2:16
Framer Update: Stack Sorting and Bento Grids
Framer Update7K views · 2 months ago
Sharing Vector Sets Across Projects (Vectors Lesson 7)3:41
Sharing Vector Sets Across Projects (Vectors Lesson 7)
Layout & Design1K views · 3 months ago
Connecting Vector Sets to the Framer CMS (Vectors Lesson 6)3:38
Connecting Vector Sets to the Framer CMS (Vectors Lesson 6)
Layout & Design2K views · 3 months ago
Animating Vectors in Framer (Vectors Lesson 5)4:25
Animating Vectors in Framer (Vectors Lesson 5)
Layout & Design4K views · 3 months ago
Customizing Vectors with Variables in Framer (Vectors Lesson 4)4:59
Customizing Vectors with Variables in Framer (Vectors Lesson 4)
Layout & Design3K views · 3 months ago
Replace component instances site-wide in Framer1:39
Replace component instances site-wide in Framer
Layout & Design4K views · 4 months ago
Creating and Organizing Vector Sets in Framer (Vectors Lesson 3)6:58
Creating and Organizing Vector Sets in Framer (Vectors Lesson 3)
Layout & Design3K views · 4 months ago

Create a free website with Framer, the website builder loved by startups, designers and agencies.