How can the parent div be made transparent without affecting the child div's visibility?

When applying opacity to a parent div, I noticed that it also affects the child div. My intention is to only apply opacity to the parent div.

I have set up separate divs for this purpose.

 <div id="container" style={{backgroundImage:"url('/images/world-map-dotted.png')",padding:'50px',height:'800px',width:'100%',textAlign: 'center',opacity:'0.8'}}>
        <div id="box" style={{height:'100%',width:'100%'}}>
          <div style={{backgroundImage:"url('/images/bg_login.png')",padding:'200px'}}>
            <h1 style={{fontSize: '30px'}}>Our Website Under Maintenance</h1>
            <p style={{fontSize:'16px'}}><b>Apologies for any inconvenience caused by our ongoing maintenance work.
              <p style={{fontSize:'16px'}}><b>For assistance, please reach out to <a></a></b></p></b>
            </p>
          </div>
        </div>
      </div>

In my design, I anticipate that only the image within the parent div will adjust its opacity without affecting the child elements.

Answer №1

If you want to adjust the transparency of a background image, one way to do it is by using a pseudo element in CSS to control the opacity. By changing the opacity of the pseudo element, you can also affect the opacity of its parent and children elements. Check out this example shared by Chris Coyier for more information: https://css-tricks.com/snippets/css/transparent-background-images/

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

Uncheck the previous option selected in a multi-select dropdown using jQuery

Hey there, I've been facing an issue with my change handler when trying to add or remove values from an Array. It works fine until the last element is selected, at which point the change event does not fire properly. Has anyone else encountered this p ...

The hierarchical structure in the DOM that mirrors an HTML table

While working on code to navigate the DOM for a table, I encountered an unexpected surprise. The DOM (specifically in FF) did not align with my initial expectations. Upon investigation, it appears that FF has automatically inserted a tbody along with sever ...

CSS - text featuring a gentle shadow hue and a deeper foreground color

I'm encountering an aesthetic issue where my list of texts have random light/bright colors, making them hard to read on white backgrounds. I've tried setting the text color to shadow, but now I want the text itself to be a darker, more readable c ...

Ensure that HTML Tidy does not disrupt meta tags, specifically schema markup

Encountering a significant issue with the latest version of HTML Tidy - visit https://html-tidy.org. To summarize: HTML Tidy is altering these HTML code lines: <div class="breadcrumbs" typeof="BreadcrumbList" vocab="http://schema.org/"> <div cla ...

Ways to substitute numerous instances of a string in javascript

I have experience in developing websites using reactjs. I usually implement restAPI's with java and work with liferay CMS. In one of my projects, I created a shortcode for accordion functionality like this: ('[accordion][acc-header]Heading 1[/ac ...

Issue with ReactJS not applying classes based on conditions

I'm currently working on toggling a class on an element when a user clicks. However, I am facing an issue where my code only sets the class for a single element and does not refresh for subsequent clicks. Even though the set class is not being removed ...

Resizing the Vue page to fit the viewport and using Flexbox to anchor the footer to the bottom

My Vue.js page structure consists of a navigation bar, main body content, and a footer: <template> <div class="flex_container"> <div class="container_navigation"> <nav-bar /> </div> < ...

Concealing Bootstrap 3 elements on a split-screen layout

I encountered a peculiar issue with Bootstrap 3. When I resize my browser width to half the screen, there is a slight 1px threshold where both "hidden-xs" and "hidden-sm" elements become visible simultaneously. Is there a way to fix this so that only one o ...

Removing scrollbar from table in React using Material UI

I successfully created a basic table using react and material UI by following the instructions found at: https://material-ui.com/components/tables/#table. The table is functioning properly, but I am finding the scrollbar to be a bit inconvenient. https:// ...

When you print, transfer HTML tags to a separate page

I need help with writing a report that pulls data from a dynamic database. I added code to force a page break after every second div tag, but since the content is constantly changing, some div tags end up spanning across pages when printed. Is there a way ...

What is the term for the visual display of a product through a photo gallery or slideshow?

Can someone help me identify what the item I'm looking for? You can click on the link to see an example of the product: sephora product example What is the technical term for the section that contains product pictures and slides? Are there any librar ...

The required keys [:id] are not included in the route matches

As a beginner in Rails, I've encountered similar issues that I can't seem to resolve. Here are my routes: resources :users do resources :items end My model setup is as follows: class Item < ActiveRecord::Base belongs_to :user end cl ...

Display a loading screen while transitioning between routes in Angular 2

Is there a way to implement a loading screen for route changes in Angular 2? ...

Trimming content within an editable div in JavaScript: A guide

I am working on an editable div feature where users can input text for comments. My goal is to eliminate any unnecessary spaces before and after the text. For example, if a user types: "&nbsp;&nbsp;Hello&nbsp;world&nbsp;&nbsp;&nbsp ...

Implementing Content-Security-Policy with React and Material-UI v4 for secure styling requirements

Utilizing a React UI with material-ui version 4, the web server is embedded within a JVM application during Production. Following npm build for the UI, the bundle is deployed alongside the server side code. An essential requirement involves implementing C ...

jQuery User interface smooth scrolling feature

When my jQuery UI dialog is minimized, it moves to a container on the left side. How can I implement a custom jQuery UI scrollbar for that container? I attempted this approach, but only received the default bland scrollbar: #dialog_window_minimized_con ...

Repurpose the identical popup window

I am searching for a solution to use the same pop-up window whenever it is called. Currently, I need to submit a form into a pop-up window and it works well, except in Chrome iOS where each form submission opens a new tab/window instead of reusing the prev ...

Tips for locating the index of the previously selected active class

I am currently working on a slider and have made progress up to this point. However, I am facing an issue where I cannot proceed because I need to identify the index of the item from which I removed the last active class before the click event occurs. My ...

Always ensure that the horizontal scrollbar is visible without the need for vertical scrolling

I'm attempting to create a data grid-style layout where the left side is fixed and only the right side is scrollable. However, the entire div needs to be vertically scrollable. The concept is functioning correctly, but the horizontal scrollbar appears ...

It's impossible for me to align two blocks at the same level

Check out the following code snippet. I am trying to group mid_left and mid_right within a single mid div tag, but struggling with positioning mid_right correctly - either outside of the mid tag or not at the same level as mid_left. I have experimented wit ...