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.