Layout & Design

Fixed, Relative, and Viewport Sizing in Framer (Fundamentals Lesson 10)

Fixed, Relative, and Viewport Sizing in Framer (Fundamentals Lesson 10)

Fixed, Relative, and Viewport Sizing in Framer (Fundamentals Lesson 10)

Joseph

·

7:06

·

68K views

·

About this lesson

Creating layouts that look and behave the way we want them to largely comes down to choosing the right sizing mode for each element.

As you know, we have several to choose from — and each has a unique purpose, depending on how static or flexible we want things to be.

Earlier in this chapter, we unpacked “Fill” and “Fit Content” sizing — but there’s also a time and place to use “Fixed”, “Relative”, and “Viewport” sizing.

Whether we want our elements to remain at a specific size, scale with our layout, or even respond to a viewer’s screen size, we’ve got options to get the job done.

So let’s dive a bit deeper into how these next three sizing methods work and when to use each one.

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

https://www.youtube.com/watch?v=REhpndQmOM8&t=6s Fixed sizing explained

https://www.youtube.com/watch?v=REhpndQmOM8&t=24s Locking aspect ratios with fixed sizing

https://www.youtube.com/watch?v=REhpndQmOM8&t=59s When to use fixed sizing

https://www.youtube.com/watch?v=REhpndQmOM8&t=36s Relative sizing explained

https://www.youtube.com/watch?v=REhpndQmOM8&t=208s Example of relative sizing

https://www.youtube.com/watch?v=REhpndQmOM8&t=262s Viewport sizing explained

https://www.youtube.com/watch?v=REhpndQmOM8&t=295s Setting full screen hero sections

https://www.youtube.com/watch?v=REhpndQmOM8&t=326s Recap of sizing and positioning modes

https://www.youtube.com/watch?v=REhpndQmOM8&t=400s 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:00creating layouts that look and behave0:02the way we want them to largely comes0:04down to choosing the right sizing modes0:06for each element as you know we have0:09several to choose from and each has its0:11own unique purpose depending on how0:13static or flexible we want things to be0:16earlier in this chapter we unpacked fill0:19and fit content sizing but there's also0:21a time and place to use fixed relative0:24and viewport sizing whether we want our0:26elements to remain at a specific size0:29scale with our layout out or even0:30respond to a viewer's screen size we've0:33got options to get the job done so let's0:36dive a bit deeper into how these next0:38three sizing modes work and when to use0:40each0:42[Music]0:43one first let's take a look at fixed0:46sizing when you drew your very first0:48frame on the canvas and manually played0:50around with its height and width you0:52were using fixed sizing it lets us set a0:55specific pixel value for a layer that we0:57want to start at that size and stay at0:59that size1:00it won't grow or Shrink with its parent1:02children or siblings there are just a1:05couple exceptions to that one we1:07actually looked at in the lesson on1:09absolute positioning where pinning two1:11opposite sides will make that Dimension1:13grow and Shrink with its parent another1:16exception is a little trick you can use1:18to lock the proportions or aspect ratio1:21of something like a photo or logo for1:23example let's say I've got a stack of1:25frames with image fills and I want the1:27width of them to fill their parent but1:30but I want the height to adjust1:31accordingly to keep the proportions of1:33the frame the same at all times starting1:37with fixed Dimensions I can make sure1:39that the images are the aspect ratio I1:41want then I'll turn on the lock aspect1:44ratio toggle now if I set the width to1:47fill I've actually locked the fixed1:50value to the fluid value and now when1:53the parent frame resizes the fixed value1:55will update dynamically to maintain the1:58aspect ratio and this happen in the2:00canvas and on the browser but those2:03couple exceptions aside a fixed2:04Dimension is going to remain static when2:07things around it resize so it's safe to2:10say we want to use fix sizing2:12thoughtfully it's great for smaller2:13elements like icons Avatar images and2:17modals and of course locking the aspect2:19ratio of media elements think of fix2:22sizing as a way to put things in a2:24protective shell that prevents them from2:26getting resized responsively but don't2:28worry we can still just fixed elements2:30for different sized devices using break2:33points but we'll get into that later2:36unlike fixed sizing relative sizing2:38allows elements to scale in relation to2:40their parent we set a percentage of the2:43parents width or height and that2:45proportion will be maintained even if2:47the parent changes size you might be2:50thinking I thought this was a job for2:51fill sizing there are a few key2:54differences first unlike fill sizing2:57relative sizing works on layers with any2:59position type including absolute and3:02fixed second relative sizing ignores3:05sibling layers and doesn't care about3:08available space you say 50% and it's 50%3:11of the parent period and third relative3:15sizing actually lets us go above 100% in3:19case we want elements to stay larger3:21than its parent by a certain amount it's3:23perfect for decorative elements in the3:24background or foreground that we'd like3:26to flex in size let's look at an example3:30here I have a giant oval forming this3:32sort of planetary element at the bottom3:34of this hero section the width and3:36height are both currently set to fixed3:38so if I preview this and play with the3:40width of the viewport nothing changes3:43which means the viewport can get wide3:45enough that the oval drops off the3:46bottom and narrow enough that we don't3:49see much curvature back on the canvas if3:52I switch the width of this from fixed to3:55relative we now see a value of 160%3:58since this layer was, 1600 pixels wide4:01and its parent is currently 1,000 pixels4:03wide on the canvas framer converts the4:06current size relationship into a4:08percentage for us automatically now if4:11we preview this the oval flexes to4:13remain 160% of the width of its parent4:16no matter how wide or narrow that is all4:19right we've got one last sizing mode to4:21learn viewport sizing which in framer is4:25specific to height viewport sizing lets4:27us set a percentage of the height of The4:29View viewers browser window AKA viewport4:32we want an element to occupy for4:34instance here we have a hero section4:37that looks really great when it fills4:39the whole browser but since we can't4:41predict the height of everyone's browser4:42window this is a job for viewport sizing4:46the unit of measurement is VH for4:49viewport height and 1 VH equals 1% of4:53the viewport height so by setting the4:55section's height to 100 VH we're telling4:58it to fill 100% of the height of the5:01browser no matter how tall the window is5:04since the nature of viewports is that5:05they vary we get a little handle on the5:08canvas that we can drag to see exactly5:10how our design will Flex in relation to5:12the browser window but nothing beats5:15checking the preview window and there we5:17have it a fullcreen hero section no5:19matter what the height of the viewport5:21viewport sizing is perfect for fullcreen5:23sections just like this one or any5:26elements that need to resize to5:28accommodate different Siz browser5:30windows and devices once again we've5:33covered a lot in this lesson but give5:36yourself a pat on the back because at5:37this point in the course you've learned5:39all of the sizing and positioning modes5:42let's recap for positioning modes we5:44have absolute where we can freely5:47position layers in relation to their5:49parent frame relative where the position5:52is determined by the flow of content in5:54a stack or grid fixed where the position5:58of a layer is fixed relative to the6:00viewport and sticky where a layer6:03switches from relative to fixed when it6:05hits the top of the viewport then back6:07to relative when it hits the bottom of6:09its parent frame and for sizing we have6:13fixed to set a specific pixel size for a6:16layer to remain at relative to set a6:19layer to a percentage of the size of its6:21parent fill to determine what fraction6:24of the available space a layer should6:25fill within a stack or grid fit content6:29to keep a parent frame snug down around6:31its relative position child layers and6:33viewport to set the height of a layer to6:36fill a percentage of the height of the6:37viewer's browser window or display6:39viewport the more you experiment with6:41these Core Concepts the more comfortable6:43you'll become so revisit the lessons in6:46this chapter remember it's perfectly6:48okay to stumble along the way take your6:51time and enjoy the process I'll see you6:53in the next one
TeachesSizing

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.