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

Activate the last div within the identical class

When I make an ajax call to fetch more results and append them to the existing ones on the same page, I want to display a scrolling spinner while the contents are being fetched. I am adding a div at the bottom of the fetched results like this: <div cla ...

Changing the position of the icon in the bootstrap validator

I'm currently attempting to validate form fields in a web project. The goal is to achieve a specific result, similar to the image below: https://i.stack.imgur.com/EVeJf.png While I have made progress with a simple solution that almost meets the requi ...

Doesn't the .stop(true) function completely clear the queue as it should?

My slideshow has a hover function to pause it using .stop(true). Upon mouse exit, it should resume playing from where it left off. However, currently, when I hover over it, the animation stops and then continues until it reaches its target, pausing there a ...

The arrangement vanishes when using identical html/css coding

When using the same HTML/CSS coding, the layout disappears and appears misaligned on one page but works perfectly on another. The issue seems to be that the first section of the main area is getting a width of 938px instead of 5px. I've tried adding w ...

Displaying limited items based on conditions in CSS

If there are 10 <p> tags, is it possible to limit them to only 5 by hiding the other 5 using CSS? Do I need to add a class five times with nth-child? Can CSS accommodate conditions for this purpose? Considering that the number of <p> tags is ...

MUI: Set the height of the div element to dynamically expand based on its content

I am currently working on styling a React app with MUI and I need help figuring out how to make a div's height adjust to its content. Specifically, I have a Card component that contains a Button. Upon clicking the Button, the content below the Card ge ...

Aligning content with CSS styling

I am facing a challenge with aligning buttons in three different td tags, as the text content within each varies. I want the buttons to line up evenly regardless of the amount of text present. Is there a solution that does not involve setting a fixed parag ...

Transform an iOS WebView into a user-friendly ebook reader

Typically, in a webview, you can scroll vertically like a browser if the page is too long. However, I am interested in transforming this experience to mimic an ebook reader. Rather than scrolling down, I would like users to be able to swipe to the next pag ...

Can you provide step-by-step instructions on how to customize styles with MUI in my application?

I am encountering issues with MUI while attempting to customize the color of my buttons. The two methods I have tried so far have been unsuccessful. For example, Method 1: import React from 'react' import { Typography } from '@mui/material& ...

Seeking a method to attach information from a div to a hyperlink

As a complete novice in the world of CSS websites, I find myself struggling to accomplish what seems like a simple task. I am working with an automatically generated CSS/JavaScript website where on the "individual" page, a person's name is listed with ...

Interested in mastering BootStrap for Angularjs?

As a PHP developer with a newfound interest in JavaScript, I took it upon myself to learn AngularJS and jQuery. However, I recently discovered that simply mastering Angular is not enough - Bootstrap is also necessary. My only issue is my fear of CSS; handl ...

How can we prevent the modal from extending beyond the boundaries of the phone screen when zoomed in

I am currently developing a web application that features a large content page, specifically a map which should display detailed information upon zooming in similar to Google Maps. The interactive elements on my map are clickable, triggering a modal popup ...

How to load several stylesheets for a component in Angular 2

Struggling with my angular2 application, I encountered an issue when attempting to load multiple stylesheets for the same component. Below is a snippet of the code: import { Component } from '@angular/core'; @Component({ selector: 'my-tag& ...

CSS: The Ultimate Guide to Fixing Your Footer at the Bottom of Your Page

My goal is to anchor the Footer to the bottom of the page. I attempted to achieve this by using Absolute positioning in CSS, as suggested in similar discussions. However, the footer seems to be behaving like a Fixed element rather than Absolute. html, b ...

A unique way to present data: An HTML table featuring four fixed columns with horizontal scrolling

I've been having difficulty creating a table with fixed first four columns while allowing the rest to scroll horizontally. I came across this example first column fixed Although the example has the first column fixed, I'm struggling to extend it ...

Obscure silhouette enveloping the text enclosure

I'm a beginner in CSS and I need to create a text box like this: My supervisor asked for a shadow effect around the box when clicked. How can I accomplish this? Any assistance would be greatly appreciated. ...

Employing PHP to iterate through and separate items into disparate divs

For my project, I need to loop through 12 items and separate them into different divs. Specifically, I want to group 0 and 1 together in one div, have 2 in its own div, 3 and 4 in another div, 5 in a separate div, and so on. <!-- Grouping 0 and 1 --> ...

Error message: ngRepeat does not allow duplicate elements in an array

Upon review, I discovered this particular piece of code: <!DOCTYPE html> <html> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> <body> <script> var app = angular.module("myS ...

Data not being displayed in dynamic <table>

Need help creating a dynamic table that displays data inserted in a specific format. {headers: ["header1", "header2"], rows: [["data1", "data2"], ["moredata", "wowoso muchdata"]]} The 'rows' consists of arrays where each array represents a row ...

Creating a rotating circle in CSS with ion-slides: A step-by-step guide

Hello, I am attempting to develop a circular object that will rotate in the direction it is dragged. Within this circle, there are elements positioned along the border so that these elements also spin accordingly. To illustrate, below are the specific elem ...