How can I center an image within a div block in Webflow, with dimensions of 140x140 and 100px radius corners? I have tried removing styles and following a tutorial, but I am unable to vertically center the image. The blue line also appears above the div instead of within it. Any suggestions?

TL;DR
  • Add a div block with a width and height of 140px and a border radius of 100px.
  • Insert the image and set its size to 100% x 100% within the div.
  • Use Flexbox by enabling it on the div block, setting Align and Justify both to Center.
  • Ensure the div has a higher z-index if overlap issues occur and check for any overriding CSS.

Centering an image within a div block can be tricky if you've already tried a few things. Here's how you can do it:

1. Set Up Your Div Block

  • Add a Div Block to your Webflow page where you want to center the image.
  • Set Dimensions: Ensure the div block has a width and height of 140px.
  • Add Border Radius: Apply a border radius of 100px to achieve rounded corners.

2. Add and Style the Image

  • Insert the Image inside the div block.
  • Make sure the image dimensions are appropriate or set to ‘100% x 100%’ to fit the div's dimensions. 

3. Use Flexbox for Centering

  • Select the Div Block containing the image.
  • Enable Flexbox: Go to the Layout section and set the display to Flex.
  • Align Center: Set the Align option to Center and the Justify option to Center. This will center the image both vertically and horizontally within the div block.

4. Adjust Z-Index if Necessary

  • If the blue line appears above the div, check that the z-index of the div block is higher than surrounding elements if they are overlapping unexpectedly.

5. Double-Check Image Positioning

  • Remove Unnecessary Margins/Padding: Ensure there’s no unwanted padding or margin on the image or div that might be affecting the layout.
  • Check CSS Overrides: Make sure no other stylesheets or custom CSS are overriding your styles.

Summary

To center an image within a div block in Webflow, set the div's display to flex, adjust the align and justify properties to center, and verify image dimensions and parent container styles are correct. This ensures the image is perfectly centered with rounded corners.

Rate this answer

Other Webflow Questions