Flex, Grid and Adaptive Layout
About this Course
In this free Webflow course, I'm teaching you how to implement and deploy a real site for Angle from scratch without a single line of code. It's going to be a fully functional site with multiple pages, advanced interactions, dynamic data, payments and animated assets from Shape.
- Final Site
- Getting Started with Webflow
- Flex, Grid and Adaptive Layout
- Components and Nav Bar
- Tabs and Advanced Layout
- Transitions and States
- Animations and Interactions
- Scroll Parallax
- Start Animation
- Lottie Animations
- Design with Data and CMS
- Symbols, Links and Pages
- Forms and Submit Data
- Ecommerce and Custom Code
Flex vs Grid
Flex is good for stacking elements in one direction and wrapping. Grid allows you to stack both horizontally and vertically at the same time. It's great for a gallery type of layout requiring gap distances. It's also a perfect replacement for the old HTML tables. Absolute positioning allows you to float elements on top of each other.
You can learn more about Flexbox and CSS Grid on the CSS Tricks site. It has a comprehensive list guide on how to use its features.
In this section we'll be learning about best practices in terms of layout. Currently, we're using margins and padding, one of the rules for reusable elements is to avoid using both of these. Instead, we should use CSS grid and flex whenever possible because not every element will need those exact margins or padding. So, we'll start by setting the margins for the Text and the Heading to 0.
Select the Content Block. In Display, select the third option i.e. Grid. For now, we don't want a gallery layout, in Columns, remove the second one by clicking on the bin icon. Enter 30 as the value for Rows in Gap. To not have the Download button take up the entire width, click on Content Block and in Alignment, select the 1st option in the second row. i.e. Align items to left.
Select the Content Block and add a Div Block element to it. By default it uses Block, go to Display and choose the 2nd option i.e. Flex. We'll be adding logos in this Div Block. To do so, select the Div Block and add an image element to it. Select the Sketch logo from the Assets we copied earlier. Right click and duplicate the image element twice. To replace the Sketch logo with the XD and Figma ones, simply click on the cog icon on the image element, then on 'Replace Image' button and select the respective images.
Select the Div Block which is already set to Flex. Set its width to 100%. Now, go to Justify and select the 4th option i.e. Space Between which is the perfect for us in this case. Please feel free to try out the other options to learn more about them. Since, the width is too big, replace 100% with 186px.
Currently, we're using padding for the Purchase Button. We'll be replacing it with Flex instead. Select Purchase and in Display, choose the Flex option. Select Vertical as the Direction and remove the padding we had previously. Set Justify to Center. This will make the button more adaptive compared to when we were setting the padding manually.
In this step, we'll learn how to make elements float on top of each other. In Purchase, add a new Div Block. In the position dropdown, select Absolute. Absolute means that the element is going to float and that it won't take any physical size unlike the elements that don't have position absolute. In Position, set Left to 0.
To make sure that it's positioned against the container and not against the entire canvas, select Purchase and give it a Position of Relative instead of Static.
Card Icon Block
Now, we'll style the box. Select Div Block 2, set its width to 64 and height to 32. Set the background color to #4312F2 and the border-radius to 10. Click on the '+' icon and choose the Icon-Card.svg file. Set its width to Auto, choose the 'X' option in Tile and Position it to left-middle. In Position, enter 34 as the value for Left. Go to the Position property for Div Block 2 and replace 0 with -15.
The final step in the section is to make the content adaptive. We'll start with tablets, click on the tablet icon to edit. Select Hero and then select the Background1. In position, replace 50% with 44% as the value of Left. Do the same for the Background2, replace 100% with 70%.
You'll notice that the properties are in Orange while the Desktop properties are in Blue, this means that the properties were inherited from Desktop. Any change you make to the tablet screen will be inherited by the mobile devices as well but it will have no effect on the Desktop.
Let's customize mobile landscape. Click on the Mobile-Landscape icon, select Container and give it a padding-left as well as padding-right of 20. Now, select Hero and enter 40% instead of 44% for Background1. To center the content, select Container and in Display, choose Flex. Justify the content to the Center by choosing the 2nd option in Justify.
To make mobile portrait adaptive, start off with selecting the Content Block and set its width to 280. Now, select the Text Span and reduce the font-size from 140 to 120. Lastly, set the font-size for the Heading to 28. Publish the site and resize your browser window to test the responsiveness.
In this section we learned a lot about flex and grid layout, about absolute positioning and media queries. In the next one, we'll learn about navigation with logo and menus. We'll also learn how to create a hamburger menu for smaller screen sizes.
Gap Rows 30
h1 margin top bottom Auto
Align self Start
Change to 3 columns
Insert Image in each column
Change to Flex
Padding top 0 (Reset)
Change to Flex, Vertical
Launch Promo Margin top 3px
Create Div Block
64 x 32px
Border Radius 10px
Background Icon-Card.svg, Width Auto, Left 34px, Top 50%, Don't Tile
Position Absolute, Top 19px, left -15px
Set Container to Position Relative
- Background2.svg Left 70%,
- Background1.svg Left 44%
- Background1.svg Left 40%
- Container, Flex, Justify Center - Padding L20, R20,
- Content Block W 280px
- h1 120px
- h2 28px
Grid areas allow you to create layout templates that you can reuse and restructure with ease. Assign grid children to these template areas, move the areas around, and watch as all of the content moves with the area — updating every instance of the layout automatically.
With grid template areas, you can:
- Create reusable page layouts
- Create radically different layouts on devices by reshuffling the areas
- Update multiple instances of a layout across your site by restructuring the grid
In this article
- Create a layout with grid template areas
- Add and position content in grid areas
- Reposition and resize grid areas
- Design grid areas for different screen sizes
- Reuse layouts with grid template areas
Create a layout with grid template areas
Once you’ve created a grid, you can define areas on your grid to create a layout template that you can reuse across your site.
Define grid template areas
You can add grid areas directly on the canvas. Edit the grid, then hover over any grid cell and click the plus icon that appears to create an area.
Once you’ve added a grid area, you can drag the corner to span and reposition the area to change its size and position. You can also click the area label and specify the position in the settings window that appears.
You can also add and specify the position of a grid template area in the Style panel.
To add an area in the Style panel, edit the grid and click the plus icon next to areas in the grid settings. To change the position of a grid area, click the area and specify in which columns and rows it starts and ends in the grid settings.
You can name grid template areas so that you can easily identify them in a grid and reuse them elsewhere in your project. It’s especially helpful to use names that specify the function of the area (eg. footer) or the type of content it should contain (eg. main image).
You can name an area on the canvas by clicking the area label while you’re editing the grid or in the grid settings in the Style panel.
Add and position content in grid areas
Once you’ve defined your grid areas, you can add and assign content to each grid area that will automatically move with the area.
Add content to a grid area
Drag and drop your content directly onto a grid template area. Once you’ve added an element, it becomes a grid child of that area.
Reposition a grid child inside an area
You can change the position of any content within the grid in the Style panel. To do so, select the element you’d like to move, set its position to “area” in the grid child settings, and specify the area in which you want to position the element.
Align content inside an area
Grid children positioned within areas will inherit any alignment settings for the parent grid. To change the alignment of a single grid child within an area, select the grid child and update the self alignment settings in the Style panel.
Learn more about grid alignment settings.
Reposition and resize grid areas
Any element within a grid template area will be move and resize with the area.
To reposition an area, edit the grid and drag the area to its new position. To resize it, drag the corner. Since areas can’t overlap, so you may need to resize areas to reorganize them in the grid before respanning them.
Design grid areas for different screen sizes
Redefining areas is particularly useful when designing for different screen sizes. Reposition and resize areas on individual breakpoints to create different layouts on devices.
Reuse layouts with grid template areas
Each template area you define is applied to the parent grid class which you can reuse throughout your project.
To reuse a layout you created with grid template areas, apply the parent grid class to another element. From there, you can drag content into the new template area and create a the same layout with new content — in just a few clicks.
Create reusable templates
So, grid layouts with defined template areas can serve as layout templates that you can reuse across your project. For example, you can create page layouts by defining a header area, a footer area, and a main content area. Or, you can define a card layout by defining an image area and a text area.
Adjust areas across multiple instances of a layout
These layout templates act like layout-only symbols. You can quickly update all instances of a layout across your site by updating a single instance of it.
But, be mindful when adjusting layouts with areas since adjusting areas affects content positioning. You can always use combo classes if you need to adjust a grid template area on a single instance.
Check the grid for responsiveness
If you’ve used the same grid layout in multiple instances in your project, go back to check your design on all pages and breakpoints. Do the same when you update any instance of a layout template.
- Make sure that all your content is positioned correctly and responsively
- Update any other styles to ensure all pages are responsive
Check the grid for accessibility
Just like manually-positioned grid children, grid areas children are explicitly defined on the grid and are similarly identified by the same icon in the navigator. What this means is that when these children move as you move grid areas, their position in the document order doesn't change. To build an accessible site, be mindful of this fact when moving areas in your grid.
Make sure you’re moving the areas for organizational purposes, and that the reading order isn’t affected by it.
Move the explicit (#) grid children in the navigator in the order you want users to read your content. This action should not affect the positioning of these children on the page.
What happens if I rename or delete an area?
When you delete an area, any grid children positioned in that area will move to auto-generated rows and columns.
To restore these children, re-add an area with the same name.
You can also manually reposition these children in every instance of the grid just change the position of each child to “auto” or “manual” positioning.
What happens if I position multiple-items into a grid area?
The content will overlap. You can reorder these elements in the navigator or use z-index to change the overlap order.
Can I add grid children in cells that are part of a grid area?
Yes, auto-positioned or manually-positioned grid children can occupy cells that are also part of an area.
For example, you can use an area to define a section in the grid by adding a background. Then, you can add the manually position header content in the grid cells.
- Create a Header area that spans the 4 columns of the first row
- Position a div-block in the header and set a background color
- Manually position a logo in column 1 row 1
- Manually position and span a navbar from column 2 to 4 in row 1
Can I define grid areas for Collection lists?
You can't define grid areas for Collection lists, but can do so with Collection items within Collection lists.
In this lesson:
- Create and edit a grid
- Place content in a grid
- Move, span, and align grid content
- Design a responsive grid
The grid layout in Webflow brings CSS grid to life on a completely visual canvas. This gives you more direct control over your layout and design. With grid, you can reposition and resize items anywhere within the grid to produce powerful, responsive layouts — faster.
You can use grid to create various layouts. For example, you can use it to create a table that you can easily convert into cards on smaller devices.
Create and edit a grid
To create a grid, select the grid element from the Add panel. You can also apply the grid layout to any existing element in the Style panel.
Edit a grid
To edit a grid, click Edit grid under Layout in the Style panel when you have the grid selected.
To exit the grid edit mode, press ESC or click Done on the canvas.
Add columns and rows
To add columns and rows, select the Add buttons that appear on the canvas or in the Style panel.
Duplicate and delete rows and columns
To duplicate or delete a column or row, right-click the column or row header and select Duplicate or Delete.
You can also delete or duplicate any row or column in the Style panel when you hover over a column or row.
Reorder rows and columns
To reorder rows or columns in the Style panel, open the grid settings and hover over the row or column you’d like to move, then drag the handle that appears.
Adjust gaps between columns and rows
Gaps allow you to specify the space between grid items without adding margin or padding. To adjust the gap size between columns and rows, click and drag the gaps on the canvas.
Or, you can enter the desired gap size in the Style panel.
Adjust columns and row sizing
To adjust the size of grid columns, select and drag the column heading to the desired size on the canvas.
You can also enter a custom size for both columns and rows in the row or column heading on the canvas or in the Style panel.
The FR unit
The grid layout introduces an extra length unit to help us define a grid: the FR unit. The FR unit represents a fraction of the available space in the grid container. You use it to define the length of rows and columns just like a percentage or pixel unit. But, unlike fixed percentages or pixel units, the FR unit automatically calculates cell space while adjusting for gaps.
Columns with a sizing value of 1FR will stretch or shrink to fill the available space in a grid container. If you add or delete columns, all columns with 1FR unit will adjust accordingly.
Learn more about the FR unit.
Setting min/max values ensures your rows and columns don’t shrink beyond a set minimum value or expand beyond a set maximum value. For example, a row has a default height of auto and will expand or shrink to fit the content inside.
If you want your rows to have a minimum height of let’s say 200px, you can set the min value to 200px and the max value to Auto. This way, the row will grow based on the content and never shrink beyond 200px. You can do the same with columns.
To enter a min/max value for any column or row, enter the desired values in the track heading on the canvas or in the Style panel.
Place content in a grid
You can add anything inside a grid: a heading, an image, a div block, and even another grid. Anything you add to the grid becomes a child element of that grid. By default, every new grid child will populate an individual grid cell — filling in the next available cell from left to right. If there are no more available cells in a row, a new row will generate to house new grid children.
Change the direction in which grid content flows
You can change the direction of the grid children by updating the direction settings in the Style panel. Here, you can select the default row setting, which places children from left to right. Or, change the direction to column, which places children from top to bottom.
Manually position content in a grid
To override the auto placement settings to manually position an item in the grid, hold Shift while you drag the element into the grid. Any item manually positioned in the grid will keep the manual position setting.
To change the position setting of an existing grid child to manual, select the grid child and update the position setting in the Style panel.
Manually placed grid children will remain in their designated grid cell. While automatically placed grid children move into the next cell to accommodate new grid children.
Nest multiple elements in a grid cell
You can add multiple elements to a single grid cell by nesting elements within the grid child. To do this, you’ll first want to add a layout element, such as a Div block, to the grid as the direct grid child.
Once you’ve added the layout element (like a Div block) as the grid child, you can add other elements to that Div block by holding Control while you drag the elements into the grid cell.
Duplicate content in a grid
There are 2 ways you can duplicate a grid child to reuse the same content in more than one cell in your grid:
- Hold Alt (on Windows) or Option (on Mac) and drag the content to create and move the duplicate into a new grid cell
- Select and copy the content, then select the grid and paste the content
Move, span, and align content in a grid
Once you’ve placed your content in a grid, you can manipulate them as you please. You can move the content around to reposition them in different cells. You can span the content to take up multiple cells. You can also adjust the alignment of the content within the grid.
Move grid children
To reposition content in the grid, select and drag the grid child to the desired location on the canvas, or in the Navigator.
Set grid child order
You can also set the order of grid children in the grid child settings section of the Style panel.
Align content in a grid
To update the alignment for all children within a grid, select the grid and change the alignment settings in the Style panel.
To change the alignment of a single grid child, select the grid child and update the self alignment settings in the grid child section of the Style panel.
Span grid children
To span a grid child across multiple grid cells, select the grid child and drag the handles that appear in the corners of the grid cell.
You can also span grid children in the Style panel. For a grid child with automatic positioning, specify how many columns and how many rows the child should span.
For children positioned manually, enter which column and row the item starts and ends in.
Watch a video tutorial on Spanning content in a responsive grid.
Lock grid child positioning
Negative grid child positioning values are great if you:
- Don't want to re-span your navbar to fill all columns each time you add new columns
- Want to keep your footer in the last row of the grid no matter how many rows you add to your grid
- Want to keep the main content section always centered in your grid
Negative numbers allow you to position children relative to the end of the grid — they reference cells from right to left or bottom to top.
To keep your navbar spanning across all columns, position it between column 1 (the first column) and column -1 (the last one).
To keep your footer in the last row of your grid at all times, position it in row -1/ -1.
If you want to keep a child centered in the grid with the same number of columns on each side, set the "end" value to be the negative equivalent of the "start" value. Example 3/-3 or 2/-2. Now if you remove columns on smaller breakpoints, the child will remain centered.
Clear grid child settings
Grid child settings apply only to the selected element and they aren't saved with the class. Pink labels in the Style panel show the changed settings applied to the selected element on the current breakpoint. These styles do cascade to lower breakpoints and are indicated with orange labels. The indicator will turn pink again when you override an inherited (orange) style on smaller breakpoints.
To remove any applied grid child setting, click the pink label, then click reset.
Overlap grid children
Grid children with manual positioning will automatically overlap when they intersect in the same cell(s). You can also control the stack order of those overlapping elements. You can do this by repositioning them in the Navigator, or by adjusting positioning and z-index settings.
Watch a video tutorial on Overlapping grid content.
Fill empty grid cells
Empty cells may remain in the grid when you have spanned grid children. To automatically populate these cells with content, enable the dense setting in the Style panel.
Note: Dense attempts to fit grid children into empty cells of your grid. This can be bad for accessibility, as it only alters where items display, not where they appear in the page’s source.
Design a responsive grid
To design your grid so it's responsive across screens, you can either manually delete columns on smaller viewports or enable auto-fit to automatically generate columns and rows to accommodate smaller screen sizes.
Manually style the grid layout across breakpoints
To make sure your grid is responsive on all devices, view your grid on smaller breakpoints and remove columns as needed.
If you can't remove columns on smaller breakpoints, try:
- Setting your grid direction to row
- Making sure you haven't manually-positioned grid children in those columns
- Making sure you don't have child elements spanning those columns
Auto-fit is one of the most powerful features of CSS grid, it allows you to repeat and wrap columns automatically so that you can build a layout that works across every single screen size — no per-breakpoint adjustments needed.
To enable auto-fit, delete all but one column and one row. Set minimum and maximum dimensions for the column and enable auto-fit.
More columns will automatically generate and repeat to distribute content responsively.
Watch a video tutorial on using auto-fit to turn a collection list into a responsive grid.
Once you perfect creating a grid, learn how to use grid areas to create reusable layout templates.
Grid webflow css
.Intro to grid — Webflow CSS grid layout tutorial
You will also like:
- Project plus netplay
- Tommy boy songs
- Nba sporcle quizzes
- Rsx gear selector
- Altima ratings
- 2021 mitsubishi eclipse spyder
- Firewomen calendar
- Crassula springtime variegated