How can Webflow center a class both vertically and horizontally on the screen, regardless of screen size or resize?

Published on
October 9, 2023

To center a class both vertically and horizontally on the screen in Webflow, regardless of screen size or resize, you can follow these steps:

  1. Create a new class: Start by creating a new class for the element that you want to center. You can do this by selecting the element and clicking on the "Add Class" button in the right sidebar.
  2. Set the position to absolute: In the class settings, make sure the position is set to "Absolute". This will allow you to position the element precisely on the screen.
  3. Set the left and top properties to 50%: Under the "Position" section in the class settings, set the "Left" property to 50%. This will move the element horizontally to the center of the screen.
  4. Set the transform property to translate: Still in the class settings, go to the "Transform" section and set the "Translate X" property to -50% and the "Translate Y" property to -50%. This will move the element vertically and horizontally, centering it on the screen.
  5. Apply a height and width: Make sure your element has a specified height and width, as this will determine the size of the centered class.
  6. Add specific positioning: If you want to center the element within a specific container, you can add another class to the container and set its position to "Relative". Then, apply the centered class to the inner element.

By following these steps, your class will be centered both vertically and horizontally on the screen, regardless of screen size or resize.

Additional questions:

  1. How do I center an element in Webflow?
  2. Can I center a specific class within a container in Webflow?
  3. Is it possible to center an element on the screen using CSS in Webflow?