What could be causing my CSS div class to cover up the image in the background?

Within my HTML code, I have a <div> that contains a whole partial view:

<div class="bkgImg">
    /* content goes here */
</div>

Inside this main <div>, there are two additional <div> elements - one without a class and one with a class:

<div>
        <h1>Content Here</h1>
        <img class="img-rounded" src="~/Content/Images/blahblah.svg" />
        <p>More Content</p>
</div>

<div class="customRound">
    <ul>
            <li>
                <a href="unimportant">
                    Languages
                </a>
            </li>
    </ul>
</div>

The "bkgImg" background displays up until the end of the first div. However, when I add a class to the second div, it appears as whitesmoke - which is the color set for the body. Why does adding a class to the inner div override the styling of the outer encompassing div?

I've attempted various solutions in CSS such as setting background to "none", "inherit", or background:rgba(0,0,0,0) to allow the original bkgImg to show, but none seem to be working!

.customRound{
    background:none;
}   

.customRound > ul{
    background:none;
    text-decoration:none;
    list-style-type:none;
}
.customRound > ul > li{
    background-color:black;
    float:left;
    height:50px;
    width:50px;
    border-radius:25px;
}


.bkgImg {
    background-image: url("Images/PrettyPicture.png");
    background-size:cover;
}

My question now is - how can I prevent the default body background from overriding the bkgImg set in the wrapping <div>? And what steps should I take to ensure no background appears on my <customRound> and <ul> elements?

Answer №1

To unveil the background of a parent element behind another, you can apply background: transparent.

Answer №2

For better layering of elements, consider adjusting the 'z-index' property by giving a lower value to the div without a class and a higher value to the element with the .customRound class.

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

Unable to retrieve the 'href' on different pages

Why am I unable to retrieve the "href" from other pages, but still can on the first page? Is there something wrong with it? Will changing the Xpath allow me to get all "href"s from every page? !pip install selenium from selenium import webdriver import t ...

Is there a way to conceal the contents of a page until all the images have finished loading?

I'm currently working on improving the performance of a website that is loading very slowly. I have already reorganized, compressed and minified the JavaScript and CSS files, but the main issue seems to be with the images. The site contains large imag ...

Using Vue3 to conditionally display a child div based on the class of its parent div

Just starting out with Vue, I'm currently experimenting with the active classes feature from this Vue3 carousel plugin. My goal is to only show the text and link divs for the carousel__slide--active class, but at the moment, all carousel__items are di ...

Achieving full white space utilization with inline block elements

When attempting to stack elements on top of each other, I encounter unwanted white space due to varying heights of the elements. I am trying to figure out how to move boxes 6 and 7 up while keeping all corresponding elements beneath them aligned properly. ...

Tips for adjusting the alignment of numbers in an ordered list to the right

Check out the code snippet below: The list items are correctly aligned to the right, but the numbers are not. How can we adjust the CSS so that the numbers align properly on the right as well? ol { width: 15vw; } <ol style="text-align:right;"> ...

Ensure that data is not cached after the page is refreshed at regular intervals of x seconds

In the process of developing a news app, I have implemented a feature where a div with the class .new_feed is refreshed every 10 seconds to fetch new updates. However, I encountered an issue where if a new feed appears in the .new_feed div and is not cli ...

My goal is to develop a table that is both able to be resized and easily repositioned

I've been working on a project to develop an interactive table that can be manipulated, resized, and repositioned within a canvas. The code snippet below shows my attempt at creating this table on the canvas: var canvas = document.getElementById("dra ...

Arrange elements in a vertical flow based on the height of the container

I am attempting to alter the direction of Elements to be vertical. Here is an example: By default, HTML elements are displayed horizontally like this:- #container { position: absolute; width: 400px; height: 200px; border: 1px solid gree ...

Using jQuery to input multiple values

Is there a way to retrieve the value from <input type="file" name="attach_1" multiple> using jQuery? I attempted to use $('input').val(), but it only returns the first file when selecting 2 or more files. ...

Utilizing the power of JavaScript in an HTML file to develop a straightforward price calculator

I am new to the world of HTML coding and currently working on an assignment for my online computer course. I reached out to my professor for help, but unfortunately, he hasn't been very responsive. The task at hand is to create a basic cost calculator ...

A step-by-step guide on uploading files from the frontend and saving them to a local directory using the fs and express modules

I'm considering using fs, but I'm not entirely sure how to go about it. Here's the setup: ejs: <form action="/products" method="POST"> <input type="file" name="image" id="image"> <button class="submit">Submit</but ...

When a dialog box is displayed, a scrollbar will automatically appear

I've encountered a strange issue while working with Angular dialogs: A vertical scrollbar unexpectedly appears, even though I've set the dialog to have a fixed width. component.ts const dialog = this.dialog.open(DialogComponent, { width: ...

Is there an issue with loading CSS and JavaScript in mobile view on a website built with CodeIgniter?

My experience with codeigniter has been great so far, but I encountered an issue when trying to view my work on different devices. Here is the problem: Web: Broswer View | Browser (Responsive Design View) Mobile: Screenshot 1 | Screenshot 2 _htaccess: ...

Two-column layout with consistent height vertically, but varying heights on individual rows

By using JavaScript, I am able to ensure that two columns have equal height. The left column contains user input which can vary in length, causing some columns to have more content than others. My current issue is that there are multiple rows instead of ju ...

How can one effectively manage a dynamic web element ID and xpath as they evolve?

After generating an XPath for a dynamic web element, I came across two nodes that are strikingly similar. The XPath used is: //*[contains(@id, "gwt-uid-")]/span[2]. Despite my best efforts to distinguish between the two nodes, I have not been successful. A ...

Deleting entries from a selection of items in a list generated from an auto-fill textbox

I have successfully implemented an auto-complete Textbox along with a styled div underneath it. When the client selects an item from the Textbox, it appears in the div after applying CSS styling. Now, I am looking to create an event where clicking on the s ...

Invoke a method in a separate class

I am facing issues with passing variables to another file. I have checked my code multiple times but cannot find a solution. It keeps giving me an error in the function. onclick="limit();javascript:AyudaTipos(2)"/> The function is: function limit ( ...

KineticJS: Applying a filter to an image does not result in the image having a stroke

Working with KineticJS version 5.1.0 I encountered an issue where a KineticJS image that had a stroke lost the stroke after applying a filter to it. I have created a demo showcasing this problem, which can be viewed on JSFiddle. Here is the code snippet: ...

What is the reason that <span> elements do not automatically wrap around to the next line when they are in line with each other without any white space?

Once upon a time, I believed that line breaks had no impact on the rendering of HTML due to minification. However, I recently discovered something peculiar. <!DOCTYPE html> <html> <body> <style> div { width: 200px; background: ...

How to continuously animate images in HTML using Bootstrap

I want to showcase 7-8 client images in a continuous loop using a <marquee> tag. The issue is that there is a gap between the last and first images. Here is the HTML code I have: <marquee> <ul> <li><a href="#&q ...