When attempting to overlay CSS text onto an image, the text appears to be hiding behind the

Essentially, what I was attempting to do was overlay some text on top of an image on a website I'm creating. After researching online, I learned that I could achieve this by using position absolute and relative, which worked to some extent. However, now my text is getting hidden under the image instead of appearing on top of it.

.lol__header {
    display: flex;
}

.lol__header-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    flex-direction: column;
    margin-right: 5rem;
    position: relative;
}

.lol__header-content h1 {
   font-family: var(--font-family);
   font-weight: 800; 
   line-height: 62px;
   letter-spacing: -0.04rem;
   position: absolute;
  right: 50%;
  left: 50%;
  bottom: 15%;
}

.lol__header-image {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.lol__header-image img {
    width: 100%;
    height: 100%;
}

React code:

const Header = () => {
  return (
    <div className="lol__ section__padding" id="home">
      <div className="lol__header-content">
        <h1 className="gradient__text">
          {" "}
          Labor of Love International Ministries
        </h1>
        <div className="lol__header-image">
          <img
            src={frontPage}
            alt="image of Pastor Wayne Preaching"
          ></img>
        </div>
      </div>
    </div>
  );
};

Answer №1

To enhance the visibility, consider adding z-index: 1 to lol__header-content h1 in the following manner:

.lol__header-content h1 {
  font-family: var(--font-family);
  font-weight: 800; 
  line-height: 62px;
  letter-spacing: -0.04rem;
  position: absolute;
  right: 50%;
  left: 50%;
  bottom: 15%;
  z-index: 1;
}

Furthermore, reorganize your HTML document by positioning your text below the image for better presentation.

Thank you and wishing you the best!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using form.submit() alongside preventDefault() will not yield the desired outcome

My login form needs to either close the lightbox or update the error box based on the success of the login attempt. I suspect the issue lies with the onclick="formhash(this.form, this.form.password);" which is a JavaScript function that hashes a passwor ...

Extracting the href attribute from a child <a> tag

I am struggling to retrieve the value of the href within the code structure below: <div class=""> <div class=""> <div class=""> <a href=""><img src=""></a> </div> </div> </div> The m ...

Comparing attribute selectors to class selectors in the realm of styling

I often come across code that looks like this: <input type="text" class="class1" name="text"> <input type="submit" class="class2" name="submit"> which is then styled as follows: input[type=text] { styles here...} input[type=submit] { sty ...

Adding a second interface to a Prop in Typescript React: a step-by-step guide

import { ReactNode, DetailedHTMLProps, FormHTMLAttributes } from "react"; import { FieldValues, SubmitHandler, useForm, UseFormReturn, } from "react-hook-form"; // I am looking to incorporate the DetailedHTMLProps<FormHTMLAt ...

Tips for creating objects with optional properties

I need help figuring out the best way to handle situations where a variable can either be defined or empty. Currently, I'm using Partial, but it doesn't provide the accurate outcome. The specific scenario involves MobX observables that begin as ...

CSS transforms fluidly transition between absolute and relative positioning

Can CSS transitions be used to combine "position: relative" and "position: absolute" in a smooth manner? I have developed a compact widget called the Deck, which has both a collapsed and expanded state. Currently, it is working well by using absolute posi ...

What happens when a page is refreshed with React Router and Express?

My query revolves around a simple question regarding an Express server with just one route. var express = require('express'); var app = express(); var path = require('path'); app.get('/', function (req, res) { res.sendFi ...

How come the hover effect is not functioning properly following the addition of padding to

I have set a padding top of 120px, but for some reason the hover effect is not working properly. Can anyone help me troubleshoot this issue? Here is the code snippet: 'use client'; // eslint-disable-next-line no-unused-vars import React, { useSta ...

The process of updating UseContext global state in React Native and ensuring that the change is reflected across all screens

Struggling with updating global state values using React useContext on different screens? Attempting to change theme color in the App, but changes only appear on the current screen and not carried over to others? Looking for assistance in resolving this ...

Dependency on the selection of items in the Bootstrap dropdown menu

I am currently struggling with a few tasks regarding Bootstrap Dropdown Selection and despite looking for information, I couldn't find anything helpful. Check out my dropdown menu Here are the functions I would like to implement: 1) I want the subm ...

Steps to ensure your Bootstrap side menu spans the entire height of the page

Welcome to my side menu <template> <div class="p-3 text-bg-dark shadow"> <div class="dropdown"> <a href="#" class=" align-items-center text-white text-d ...

React Router relies on a DOM for Browser History to function properly

I am currently developing my app using React.js and express. My main focus right now is setting up react-router-dom for the application. Unfortunately, I encountered a warning when attempting to run the app: Invariant Violation: Browser history needs a ...

Adjust the display from none to block when the parent element is set to flex

JSFiddle Demo Issue with - .popupcard_first:hover .popupcard_first { display: block; } I am trying to link the :hover effect to the first card only, but the only way I could make it work is by changing .popupcard... to .featured_cards:hover .po ...

Creating a dynamic multi-item carousel with Materialize (CSS) cards using data from a loop - here's how!

Using a for loop, the following code generates a list of cards. These cards are intended to be displayed in a carousel with 4 cards visible at once, and a next arrow button allows users to navigate through the next set of 4 cards. Materialize cards have ...

The Width of Material UI Divider

Currently seeking a method to increase the line thickness of the Material UI Divider, whether by stretching horizontal lines vertically or stretching vertical lines horizontally. I have reviewed the documentation for Material UI v5 on https://mui.com/mate ...

What steps should I take to ensure that clicking this button triggers the API request and returns the data in JSON format?

I'm attempting to have the button with id 'testp' return an api request in json format, however it seems to not be functioning properly. You can find the HTML code link here: https://github.com/atullu1234/REST-API-Developer-1/blob/main/js-bu ...

The Bootstrap modal stubbornly refuses to close even after resetting the HTML body

I am having an issue with my bootstrap modal where the closeModal button is not functioning properly after the printModal button has been clicked. The modal does not close as expected. Step 1: Click on the printModal button after the modal pops up (this w ...

Clicking outside the parent component's DOM hierarchy will trigger the insertion of a new instance of a component

I want to generate a new component called <CreateLine/> each time the user clicks instead of updating the existing DOM node. // Clicking will create a separate instance of the CreateLine Component and add it to the Create Area as a Child. < ...

What is the best way to add an image element as a child of a list item only when its sibling checkbox is checked, upon clicking another button?

As a beginner in jQuery, I am working on developing a game where users can select and check 3 images from a list of ten. Following this selection, I aim to have the checked images added to a separate unordered list that I have already set up. <ul id="i ...

The error `Error occurred when rendering: Users' data cannot be mapped` indicates a problem with the rendering process

Utilizing useSWR for data retrieval from an endpoint and attempting to display all returned data, I encounter the following error: unCaught (in promise) fetchedUsers.map is not a function uncaught TypeError: fetchedUsers.map is not a function The provided ...