disregard the background styling applied to the parent element with the class of `.wrapper`




I am completely new to all of this, so please bear with me. Here's my current situation:

So, I've set a background image for the entire body of my website. I have a div called .wrapper that I use on all of my pages. Its main purpose is to keep my content centered and organized, with a grey background color defined. Now within the .wrapper div, there is another div titled .example.

The problem arises when I want this specific .example div to have the background image of the body instead of inheriting the .wrapper's background color. However, I still want it to maintain the other properties of the .wrapper. Is this even possible? I attempted not to set the background-image of the .example the same as the body’s because it seems like an "outsider" element...

<html>
...
<body>
<div class="wrapper">
    <div class="example">
        <img src="example.png">
    </div>
</div> <!-- Wrapper -->
</body>
</html>

body { 
    background: #ffffff url("bg.jpg") repeat;
    background-size: 4%;
    background-position: center;
} 

.wrapper {  
    width: 80vw;
    margin: auto;  
    padding: 0px 0px;
    background: #e9eaed; 
    display: block; 
}  

.example {
    width: 100%;
<!--   background-color: #f6c5b6;-->

}

.example img {
    width:40%;
    margin: 40px auto;
    display: block;
}

Answer №1

To successfully implement this, you must construct your div based on it.

.body {
    background-image: url('http://placekitten.com/g/40/40');
    width: 500px; height:700px; background-repeat:repeat;
}
.wrapper {
    width:300px; height:50px; background:grey; margin:0 auto;    
}
.mask {
    width: 300px; height:100px; margin:0 auto; 
}
.left {
    width: 50px; height:100px; float:left; background:red;
}
.right {
    width: 50px; height:100px; float:right; background:red;
}
<div class='body'>
    <div class="wrapper">
        box 1
    </div>
    <div class="mask">
        <div class="left">
            box 2
        </div>
        <div class="right">
            box 3
        </div>
    </div>
    <div class="wrapper">
            box 4
    </div>
    
</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

Persistent Footer - Attemping to keep footer anchored to the bottom of the page

Today, I am facing a sticky footer issue that is rather frustrating for me. Despite trying various resources and conducting thorough searches, I am unable to identify what is causing the problem with my footer. I would greatly appreciate any help in resolv ...

Extract the td elements from a table with specific class using the DataTable plugin

I stumbled upon this snippet of code while browsing through the DataTable website. var table = $('#example').DataTable(); table.column(0).data().each(function(value, index) { console.log('Data in index: ' + index + ' is: &apos ...

Is there a way to update or modify the media queries set in the Bootstrap CSS file

I don't want the media queries defined in the Bootstrap CSS to override my custom CSS when the user resizes their window. Here is my HTML code: <div class="row"> <div class="col-xs-6"> <dl class="dl-horizontal dl-horizontal-info custo ...

Revamp HTML <font size=1-7> with the use of CSS or JavaScript

I've been developing a prototype application that incorporates a plugin utilizing the deprecated HTML feature. Can I set custom pixel sizes for each font size ranging from 1 to 7? Currently, I'm contemplating using CSS zoom/scale properties, bu ...

The variables are filled with HTML tags that will render the display in

I am facing an issue with displaying HTML tags in my website. When I try to print a variable containing HTML tags in the tpl file, it shows the tags along with the content. This is how it looks in the PHP file: $content = "<h1>Header</h1>< ...

If the font size exceeds a certain value in SCSS, then apply a different value

Can SCSS handle this scenario? I am looking to set the font size to 22px in case it is greater than 30px, especially within a media query for a max width of 480px. ...

Completely place one element with respect to its sibling element

I am currently facing a situation where I have implemented a Navigation bar wrapper that reveals an overlay across the entire page when clicked. In order for this setup to function correctly, all the elements that the overlay covers must be sibling elemen ...

"Discovering the method to access the most recent clicked event data across the entire JavaScript scope

function retrieve_data(){ var information = $(this).data(); // this is undefined console.log(information.crm); } $(document).on('click', '#add_info', (function() { var info = $(this).data(); // this works console.log(info.c ...

Include a carrot icon on a navigation element that is currently active, ensuring it does not disrupt the position of the navigation icon within the container

I am working on a react navigation bar where I want to emphasize each navigation item with a carat when the user is on a specific URL or route. I have been trying to use the :after pseudo-class in Sass to add the carat, but it's not working as expecte ...

Using javascript to color in cells of a grid of "pixels"

I have a project similar to an Etch-a-Sketch in progress. The main challenge I am currently facing is how to gradually darken each cell of the grid with every pass of the mouse cursor, based on the opacity of the cell being hovered over. When the grid cell ...

Styling with CSS: A guide to reducing paragraph margins within a div element

My current project involves using javascript to dynamically insert paragraphs inside a div element. Essentially, the script grabs the value entered into an input form when a button is clicked and adds it as a new paragraph within a specific div. However, I ...

"Learn how to specifically extract parent <li> elements without including the child <li> elements

When attempting to crawl a website [URL: https://www.khaasfood.com/shop/], my first task is to retrieve the categories with their hierarchy. The .container element contains a list of li tags representing parent categories. Each parent category may also h ...

Struggling to determine if the checkbox has been ticked?

I have integrated a like button on my website using socket io to ensure that it updates for all users when the like button is clicked. I have successfully implemented a like() function that emits liked, increments a counter, and displays it on the page. Ho ...

I am looking to arrange two div elements and one navigation bar into the header, positioning them at the top-left, top-center, and top-right using CSS. How

I'm attempting to arrange three divs within the <header>: div1 (logo) at the top left of the page, nav2 (menu bar) at the top center of the page, and div3 (social networks) at the top right of the page. However, I am unsure of how to achieve thi ...

Transform an HTML website into a collaborative wiki platform

I currently have a simple HTML website (no JavaScript, PHP, or CSS) with over 1000 pages that I want to transform into a Wiki format. I need a converter to extract the content from each page and create individual wiki pages for them. Additionally, all the ...

Creating a personalized CSS class for TYPO3 menu links

I am currently in the process of creating a brand new website using TYPO3 6.2 and incorporating the Bootstrap Package. My goal is to be able to assign custom CSS classes to menu links directly from the backend, and then display these CSS classes within my ...

Fade in and out HTML divs using jQuery with customizable timing intervals

I'm attempting to alter an existing solution here by incorporating a total of 7 divs that have fading in and out effects, all within the same space on the page. The sequence should loop back to the initial div after reaching the end. In addition, I r ...

Modify the currently selected color in a multi-select menu by editing the option tag

Why does the selection option value turn blue, but then become a faint grey when clicking on anything else on the page? Can these colors be changed, especially the faint grey for better accessibility? I've experimented with various CSS approaches, bu ...

I am encountering an issue where I am unable to access properties of null while trying to read the 'pulsate' function within the

The current version of my material-ui library is as follows: "@mui/icons-material": "^5.5.1", "@mui/material": "^5.5.1", This is how I included the Button component : import Button from "@mui/material/Button&qu ...

Tips for effectively utilizing the count() function within selenium's xpath feature?

By utilizing the count() function within XPath, we can extract the total count of matching nodes instead of using findElements() and size() methods. Do you know if the count function in XPath returns an integer value? For example, Let's say my xpath ...