What is the best way to place text on top of an element with a background opacity of 0

.c{
    display: flex;
    padding-top: 18em;
    .backgroundDiv{
        background: url("/images/DSC8253.png");
        background-repeat: no-repeat;
        background-size: cover;
        background-position: center center ;
        height: 20em;
        opacity: 0.6;
         position: absolute;
         width: 100%;
         z-index: -1;
         
    }
}
.bigText{
    display: flex;
    text-transform: uppercase;
    font-size: 3em;
    font-family: cursive;
    font-weight: 600;
    height: 8em;
    top:2em;
}
 <section class="c">
         <div class="backgroundDiv"></div>
         <div class="bigText">
             <p>Pilki-HUILKI</p>
             </div>
     </section>

Answer №1

To style the content in your CSS file, make the following adjustments:

.c {
  display: flex;
  position: relative;
  height: 100vh;
}

.backgroundDiv {
  background: url('/images/DSC8253.png');
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center center;
  height: 20em;
  opacity: 0.6;
  position: absolute;
  width: 100%;
  z-index: -1;
}
.bigText {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  text-transform: uppercase;
  font-size: 3em;
  font-family: cursive;
  font-weight: 600;
}

I'm using absolute positioning to overlay the text on the background image and then applying a transform to center it.

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

preventing the ball from landing inside the container (JavaScript)

I developed a straightforward website with the following functionality: Upon entering any text into the prompt and clicking okay, a ball will drop into the 1st box, namely the Past Thoughts box. Below is the code snippet: HTML <h1> Welcome t ...

Creating an element that remains fixed once it reaches a distance of 50px from the top of the screen

Hey there! I'm working with an html div element that currently scrolls along with the page, but I was wondering how I can make it become fixed once it reaches a distance of 50px from the top of the screen. Any ideas on how to achieve this? Just to pro ...

Finding the file in a separate directory within the src path

In my projects directory, I have a folder named projects which contains both a game folder and an engine folder. Inside the engine folder, there is an engine.js file. My issue is that I want to access this engine.js file from my game.html file located in a ...

Trouble with PHP file uploads

Greetings! I am a developer coming from an ASP.NET background, new to PHP. Recently, I transitioned to PHP as I needed to create a website for a friend. However, I encountered a persistent error message while trying to upload music files to a specific fold ...

The 'change' event in AJAX does not trigger when the value 'select value is assigned from PHP

I have a form that includes fields for city, state, and country. The goal is to automatically populate the state and country fields when a city is selected by retrieving data from a MySQL database using Ajax. However, I am facing an issue where the Ajax c ...

Is it possible to center my tab on the page and add captions as well?

Struggling to align a tab with 3 image buttons in the middle, I resorted to using manual margin adjustments. I also added captions separately from the buttons for aesthetic purposes, but know this is not the correct way. Is there a way to attach the captio ...

The speed of the mobile website is dragging down the user experience on my

I'm working on creating a prototype for the mobile version of a website, utilizing only jQuery and Foundation 4 with no dynamic elements. Unfortunately, when I view the site on an iPhone browser, it loads very slowly and is unresponsive to touch comma ...

How come my script that is dependent on the viewport does not apply classes?

I created a code to add a class to a div, but it's not working as expected. I need help troubleshooting this issue. The code works fine on codePen, but not on my WordPress website. How can I make sure the browser executes this code properly? Link to ...

Displaying a CSS span element as the topmost layer

I am struggling to get a tooltip to properly display on top of its parent element. Despite trying various combinations of z-index and overflow properties, I have not been able to achieve the desired outcome. The issue arises when hovering over the red box ...

Attempting to modify the contents of a div by utilizing the CSS :hover pseudo-class

I recall seeing this technique used before, but I am struggling to remember where. My goal is to modify the content of a div when the css :hover state is activated. Below is the CSS code that I am attempting to make work: .mWin_close:hover div.new-label ...

angular material drag and drop triggers a callback once the css transition has completed

I have successfully implemented a list of elements that can be dragged and dropped using Angular Material's drag and drop feature, similar to the tutorial available at this link. In my implementation, I have a "drop(event)" function that not only mov ...

Is it feasible to add a row in bold font following every set of 10 rows written in regular text?

Looking for a way to implement pagination on a table with dynamic headers? I am using rows with font-weight:bold to act as headers for the pagination. Is it possible to insert a row with font-weight:bold every 10 rows? I am unsure of how to achieve this, ...

Attempting to align HTML lines in a more compact manner

I can't seem to figure this out - I'm trying to stack three lines of text (one small, one big, one small) with single-spacing between them. However, no matter what I try, the larger font line always ends up with a double-space above it (for examp ...

Changing color when mouse hovers using Jquery

Currently, I am in the process of converting a flash ad into an html5 ad. I found this demo here, and I would like to replicate the mouse hover effect showcased. When the cursor hovers over the details text in the banner, the entire background changes to ...

Adjust the size of multiple elements upon hovering over one of them

I encountered a puzzling issue, and here is a demonstration of my problem: https://jsfiddle.net/k1y8afst/ <div class="Sample"> <div class="Dummy"> <div class="Books"> <a st ...

Prevent the bootstrap header in a table from scrolling by enclosing it in

I am encountering an issue with fixing the headers of multiple tables in a page within their dedicated divs. Despite trying various methods, I haven't been successful as the fixed header overflows the div. I want to confine it within the div. Additio ...

Optimal methods for managing CRUD tasks in databases and user interfaces

When it comes to making a design choice and following best practices, I have a question in mind. Imagine a user has access to a user interface that displays data from a MYSQL table using an HTML table. This user can also perform CRUD operations on this dat ...

Lint error: Unrecognized attribute 'text-fill-color' in CSS (unknown properties)

My navigation bar isn't functioning, and I can't figure out why. It seems like it might be related to this snippet of code: -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; text-fill-color: trans ...

I am looking for a way to save a webpage as .html/.png format after entering text in the text box. Here is the code I have

Is it possible to download a webpage as .html/.png after inputting text in the text box? Here is my code: <div class="container"> <form> <div class="form-group"> <label for="link">Paste Website Link Below</label> ...

A comprehensive tool for testing JavaScript, CSS, HTML, and jQuery code

Currently, I am working on an extension for Google Chrome that consists of multiple .js, .css, and .html files. My coding process involves using Notepad++ as my primary tool. However, I find myself needing to conduct testing at various stages of developm ...