To overlay text on an image within a section in Webflow, you need to use relative and absolute positioning. Here's how to do it effectively.
1. Add a Section and Background Image
- Drag a Section onto the canvas from the Add panel.
- Click the section, go to the Style panel, and set a background image under the Backgrounds settings.
- Choose "Cover" for the size and "Center" for the position to ensure the image scales and centers properly.
2. Set Section to Position: Relative
- With the section still selected, scroll to the Position setting in the Style panel.
- Set the position to Relative. This allows absolute-positioned child elements to align relative to it.
3. Add a Text Block or Heading Element
- Drag a Text Block or Heading into the section.
- Select it and in the Style panel, set its Position to Absolute.
- Choose the specific location (e.g., Top Left, Center, Bottom Right, etc.) or set top, bottom, left, right values manually for precision.
- You can also apply padding/margin and adjust text alignment, font size, and color for styling.
4. Optional: Add an Overlay Layer
- To darken the image and improve text readability:
- Drag a div block into the section above the image layer (but below the text).
- Set the div’s Position to Absolute and set all sides (top, bottom, left, right) to 0 to make it fill the section.
- Apply a semi-transparent background color (e.g., black at 50% opacity).
5. Ensure Proper Layer Order
- If the text is hidden behind the image or overlay:
- Adjust the z-index of the text (e.g., set it to 10) to bring it above other layers.
- Make sure the overlay layer has a lower z-index than the text but higher than the background.
Summary
Set your section to Relative, use Absolute positioning on your text element, and optionally add a semi-transparent overlay div to improve readability. Always manage z-index values to maintain the correct layer order.