Webflow Layout Techniques

Aspect Ratio

Overview
Responsive Layout Techniques
102
Element Layouts
Aspect Ratio
201
Responsive Image Annotations
6:50
202
Collection List Alternating Item Layouts
4:32
601
Collection Page & Collection List Layouts
Collection List Card Layouts
4:32
601
Creating Variable Layout Options, per Collection Item
11:46
602
Random List Items on Every Page Refresh
10:00
603
Variable Collection Item Sizes in a Grid Layout
603
Limit Collection List Items by Breakpoint
10:00
604
Hide Collection List on Empty, or Item Qty
605
Responsive Pagination
605
Masonry Grid Layouts
607
Glossary w/ Letter Groupings
612
Comparison Grid Layout
612
CMS Style Multiref-Matched Items
11:00
614
Master-Detail Layouts
Master-Detail Layouts
710
CMS-Driven Expando
19:42
714
Special Layouts
Creating Leader Lines
5:54
821
Photo Gallery Layouts
821
Column Layouts
822
Text Layouts
823
Checkerboard Grid Styling
824
Tetris Grid Layouts
12:00
826
Advanced Techniques
Breakpoints
901
No items found.
Published
November 13, 2022
Updated
in lightbox

Once in awhile I come across a need to control an element's aspect ratio, while giving it the freedom to scale with the layout.

Recently I needed this for an circular icon container, constructed like this;

<div><svg>...</svg></div>

The circle containing the icon needed to scale as a % of its parent, but how to keep the height of that container fixed 1:1 with the width, so that it would remain a perfect circle?

CSS to the Rescue

There are probably several ways to do this in Webflow, and I need to look into them, but I immediately wondered whether CSS has a built-in way to specify aspect-ratio.

And in fact, there is. It's called aspect-ratio.

.element {  aspect-ratio: 1 / 1; /* a perfect square */ }

The general format is;

aspect-ratio: auto || <ratio>;

Learn more

The DIV padding Approach

Another approach commonly seen in responsive sites that use video embeds, is to use nested DIVs with a particular CSS trick for padding.

It looks like this;






</div>

There is a nice write-up on SO here;

Maintain the aspect ratio of a div with CSS

FAQs

Answers to frequently asked questions.

Videos
No items found.
Table of Contents
Comments
Did we just make your life better?
Passion drives our long hours and late nights supporting the Webflow community. Click the button to show your love.