Can you clarify if there is a specific sequence for overlaying the image in the img tag as a background image?

The li class has a background image inserted into it.

Inside the li class, there is an img tag.

How can you make the background image of the li class tag take up more space than the top?

<style>
.wrap {
    width: 100%;
    overflow: hidden;
    position: relative;
    height: 625px;
}
.ul-wrap {
    width: auto;
    position: relative;
}
li.full-image.guest_bulr {
    background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAQElEQVQoU2NkIAJ4e3sbMxJSB1K0devWs3gVwhSBDMOpEFkRToXoirAqxKYIQyEuRSgK8SmCKySkCKyQGEUghQBteCUf8jBb4wAAAABJRU5ErkJggg==);
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 980px;
    height: 625px;
    z-index: 999;
    display: none;
    background-color: rgba(21, 18, 18, 0.9);
    zoom: 1;
    background-size: cover;
}

.wrap img {
    max-width: 100%;
    display: block;
}

</style>

<div class="wrap">
    <ul class="ul-wrap">
        <li>
            <img src="http://placehold.it/980x625/?text=image-1st" alt="image" class="first-img">
        </li>
    </ul>
</div>

Answer №1

Make sure to use the .first-img class with relative positioning. You can find a working example below.

.wrap {
    width: 100%;
    overflow: hidden;
    position: relative;
    height: 625px;
}
.ul-wrap {
    width: auto;
    position: relative;
}

.ul-wrap li {
    background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAQElEQVQoU2NkIAJ4e3sbMxJSB1K0devWs3gVwhSBDMOpEFkRToXoirAqxKYIQyEuRSgK8SmCKySkCKyQGEUghQBteCUf8jBb4wAAAABJRU5ErkJggg==);
    display: block; 
    position: relative;
    width: 980px;
    height: 625px;
    background-size: cover;
    background-color: rgba(255, 0, 0, 0.4);
}

.wrap img {
    max-width: 100%;
}

.first-img {
    position: relative;
    z-index: -1;
}
<div class="wrap">
    <ul class="ul-wrap">
        <li>
            <img src="http://placehold.it/980x625/?text=image-1st" alt="image" class="first-img">
        </li>
    </ul>
</div>

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

Clicking on an item causes it to move to the following line

Whenever I click on the third (bottom) line in the pagination block, the number item 30 keeps jumping to the next line. You can see it happening here. This issue only occurs in the Chrome browser. It seems like there might be a problem with the CSS. Can ...

How to set the innerText of an href element in C# with content that begins with ~/

I am working on a web application using asp.net/c# 4.5 Within my front-end code, I have an href element that looks like this: <a href="" id="myhref" runat="server"> my text </a> My goal is to dynamically set the ...

transforming the use of getelementbyid into a plural form

Can a getElementById function work in plural context? Or would I need a different function or maybe jQuery? <script type="text/javascript> window.onload = function() { var test = document.getElementById('test'); if ...

Developing 2 potential results from textarea input using NODE.JS and HTML

Today, I encountered an issue while working on my bot website project that responds to textarea input. When I attempted to test it with two different commands, one of the commands stopped working unexpectedly. I'm puzzled by this and would greatly app ...

Issue with Three.js GLTF loader peculiar behavior while attempting to incorporate three-dimensional text

I had an idea to import a prebuilt gltf scene created in Blender, then add some 3D text using the ttf loader and manipulate it. Each loader worked perfectly when used separately, but strange things started happening when I combined them into a single scrip ...

Centered label above an inline input form

I'm struggling with aligning inputs under long labels in a form. I want the input fields centered under each label while keeping them inline. The desired look is shown below: https://i.sstatic.net/itJCY.png The current code I have is not achieving t ...

Reveal a concealed div upon submitting an HTML form to display the resulting output

I have created an HTML form to gather information about a person's name and location. Once the user submits the form, I want the output to be displayed at the bottom of the page using PHP echo. My specific requirement is, To initially hide the outp ...

Showcasing the nested json data along with images in a table using plain javascript

I am looking to display nested JSON data containing images in an HTML table using vanilla JavaScript. I have tried different approaches but haven't been successful in achieving the desired result. You can find my code on Codepen. Here is the expected ...

the value contained in a variable can be accessed using the keyword "THIS"

I recently developed a snippet of code that adds a method to a primitive data type. The objective was to add 10 to a specified number. Initially, I had my doubts about its success and wrote this+10. Surprisingly, the output was 15, which turned out to be ...

CSS-Only Menu Fails to Function with Image Overlayed on Top

I need help with a website I created where I want the header to be placed slightly on top of my CSS menu. However, when I overlay an image, I lose my CSS menu and I am looking for a way to keep it while still displaying the image. My goal is to have the C ...

"Encountered a broken image while attempting to send a response with the content-type set as

Within my frontend html, I am looking to include an img element with the source link '/uploads/profilePicture'. In my node/express setup, I need to verify the user's authentication, retrieve their profile picture from the filesystem, and ret ...

Enhance the slider's worth

Hey there, just wanted to mention that I didn't write this code myself. Another person did, and I'm a bit lost trying to figure out how to assign values to the three sliders. I don't want a default value; I want each slider to take its value ...

Engaging in payment processing

Currently facing a significant dilemma. I am utilizing Stripe as my payment gateway, which functions in a two-step process: Collect billing information to generate a token Charge the client using the generated token The issue arises because the token ca ...

Displaying images using <img src='path' /> in React is causing some troubles

I'm currently working on a React template for the front page and I need to display various local dummy images. Within my <Main /> component, I import other components that pass the image path as a parameter, like this: <Container type ...

Is the scroll navigation bar transparent on the right edge?

Below is an image attachment showing a navigation bar with list items. The overflow-y property allows scrolling to the right and left, and the desired effect is to make only one side transparent at a time based on the scroll direction. Is it possible to ac ...

Enhancing the appearance of the content editor with a personalized touch

I am working with a standard content editor that utilizes an iFrame as the text area. Upon changing dropdown options, it triggers the following command: idContent.document.execCommand(cmd,"",opt); Where "idContent" refers to the iFrame. One of the dropd ...

Can a submit button be created that integrates both a radio button and submission functionality?

Is there a way to combine a radio button and submit button into one element for submitting the value just with a click? Currently, I have a radio button and a separate submit button in my code, but I want to streamline it. This is the current code snippet ...

What is the best way to ensure that form inputs and labels stay aligned?

Let's consider a scenario where there is a web page containing a form: <form> <label for="FirstName">First:</label> <input name="FirstName" type="text"> <label for="MiddleName">Middle:</label> <input n ...

Components from Bower are currently not available

Trying to automate the injection of bower components into my HTML using grunt-wiredep. It seems simple enough, but I'm having trouble setting the correct path to the bower directory when running localhost. Currently, I'm receiving this error: ht ...

The menu appears with a gentle fade and smoothly descends into place

I am embarking on my first venture into creating an animated menu. Take a look at this image to see what I have in mind: The arrows serve as a visual representation of my desire for the names to drop down and fade in when the menu button is clicked. Addi ...