CSS Viewport Units in Webflow: Understanding and Implementing VH, DVH, and SVH

Published on
May 13, 2023

Understanding CSS Viewport Units in Webflow

If you've been using VH (viewport height) to set the height of elements like sections on your website, you may have encountered some unexpected behavior. In this tutorial, we'll delve into the intricacies of viewport units in CSS and how to use them effectively in Webflow.

The Problem with VH

Many designers set the height of sections to 100VH (100% of the viewport height), expecting it to remain consistent across devices. However, the issue arises when the viewport height changes on different devices due to dynamic toolbars and varying browser UI elements. As a result, what you expect to be 100VH might not appear as intended on certain devices.

Enter DVH and SVH

To address this issue, some designers advocate for using DVH (dynamic viewport height) as an alternative. While DVH can adjust the content based on browser UI elements, it comes with its own set of challenges. When the browser UI, such as a toolbar, appears or disappears while scrolling, the section's height changes dynamically, potentially frustrating website visitors.

Now, let's introduce SVH (small viewport height) as a potential solution. SVH calculates the height similar to DVH when the page loads but does not resize itself based on changes in the browser UI. This makes SVH a promising alternative, offering the best of both worlds by ensuring a consistent appearance without being affected by dynamic browser elements.

The Perils of Setting Heights in CSS

While SVH seems like a viable solution, there's a crucial consideration when it comes to setting heights in CSS. If you set a specific height for a container, such as a div or section, and it contains content, there's a significant risk. This risk applies to any unit of measurement, including SVH, VH, pixels, or rems. When a height is explicitly defined, it disregards the content inside, potentially causing overflow and layout issues on different devices.

Best Practice: Using Minimum Heights

To mitigate the issues associated with explicitly setting heights, a best practice is to utilize minimum heights. By setting a minimum height for a section, it ensures that the content inside dictates the actual height of the section. This allows the section to expand as needed based on the content while also preventing it from becoming shorter than the specified minimum height.

In Webflow, you can easily set the minimum height of a section to 100SVH or any other desired unit, ensuring a responsive and visually consistent design across various devices.

Implementing Viewport Units in Webflow

Now that we've explored the intricacies of VH, DVH, SVH, and the importance of minimum heights, let's discuss how to implement these concepts in Webflow.

When building a website in Webflow, you can leverage the power of the Designer interface to apply viewport units to your elements. Whether you're setting the height of sections, containers, or other elements, Webflow provides intuitive controls for defining dimensions using VH, DVH, SVH, and minimum height properties.

To configure the height of a section in Webflow, you can select the desired section on the canvas and navigate to the styling panel. Within the styling panel, locate the height property and choose the appropriate unit, whether it's VH, DVH, or SVH. Additionally, you can set the minimum height to ensure that the section dynamically adjusts based on its content.

By utilizing these features in Webflow, you can create responsive designs that adapt seamlessly to different viewport sizes and browser UI variations.

Conclusion

In conclusion, understanding the nuances of CSS viewport units and their implications for responsive web design is crucial for delivering a consistent user experience across devices. While VH, DVH, and SVH offer varying degrees of responsiveness, it's essential to consider the impact of explicitly setting heights in CSS.

When working in Webflow, harnessing the capabilities of viewport units and minimum heights empowers you to create visually compelling and adaptable designs. By incorporating these principles into your design workflow, you can ensure that your websites look and function impeccably on diverse devices.

With this knowledge and the tools provided by Webflow, you're well-equipped to build dynamic and visually appealing websites that seamlessly adapt to the ever-changing digital landscape.