I'm having trouble understanding why a black div with opacity set to absolutely positioned doesn't cover a specific element

I am facing an issue with a modal window that includes an absolutely positioned black div covering the entire viewport when the modal is open. Strangely, this black screen fails to cover a specific element even though it should. This particular element remains visible despite the overlay. I cannot figure out why this specific element is not being covered while everything else is.

.black-screen {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.8);
}

The element causing the issue:

<div class="form-container">
    <form class='send-message'>
        <input class='message-input' placeholder="Type a message">
    </form>
</div>

Here is the CSS for that element:

.form-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}
.send-message {
    position: relative;
    padding: 20px 0px 20px 20px;
    flex: 1;
}
.message-input {
    width: 100%;
    padding: 15px;
    outline: none;
    border: none;
    background-color: #40444b;
    color: #dcddde;
    font-size: 14px;
    border-radius: 5px 0 0 5px;
}

Answer №1

By making a few tweaks to the CSS code, I can only make educated guesses (CSS cascades and inherits properties).

.form-container {
    position: relative;             /* let's try removing this */
    display: flex;
    justify-content: center;
    align-items: center;
}
.send-message {
    position: relative;             /* let's try removing this as well */
    padding: 20px 0px 20px 20px;
    flex: 1;
}
.message-input {
    width: 100%;
    padding: 15px;
    outline: none;
    border: none;
    background-color: #40444b;
    color: #dcddde;
    font-size: 14px;
    border-radius: 5px 0 0 5px;
}

If it's not feasible or doesn't yield results, you can replace the div elements, although there's uncertainty about browser compatibility...

<div class="form-container">
    <form class='send-message'> <input class='message-input' placeholder="Type a message">  </form>
</div>
<div class="black-screen">black</div>

If the issue persists, consider using W3C Validator to assess the severity ... actually, using the Validator is recommended regardless.

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

Creating a table of variable covariances

I'm interested in generating a covariance table that displays all possible combinations between 3 to 10 inputs. The illustration below demonstrates an 11x11 table for 10 inputs and a 4x4 table for 3 inputs. Users have the flexibility to select anywhe ...

Guide to making a custom scoreboard in JavaScript for my gaming application

Being a beginner in coding, I've been working on a Battleship-like game. I've managed to do most of it, but the scoreboard isn't functioning. I'd appreciate any guidance on how to fix it or what changes are needed for it to work properl ...

Using ReactJS with Typescript and react rewired to load CSS module

I am currently setting up a proof of concept project using ReactJS and typescript, and I want to incorporate CSS modules without ejecting the webpack configuration. Here are the steps I have taken so far: Installed create-react-app globally - npm install ...

Can you provide me with instructions on how to change the background image?

Having trouble with the CSS code I wrote for a background-image. It's not showing up when I set it in my CSS stylesheet. I tested it and found that it only works when written in the body... <body background="Tokyo.png"> ...but not in the styl ...

I have written code in JavaScript, but now I am interested in converting it to jQuery

What is the best way to convert this to jQuery? showDish("balkandish1") function showDish(dishName) { var i; $(".city").css('display', 'none'); $("#" + dishName).css('display', 'block'); } ...

Styling an input text using CSS and Jquery without relying on a parent

Styling CSS input text without a parent div Hello everyone, I am looking to remove the <div id="input_container"> from the code below. Is it possible to achieve the same result without that surrounding div? Check out the jsfiddle: http://jsfiddle.n ...

Creating a JSON file using the attributes and values of HTML tags

I am seeking assistance in generating a JSON file from HTML data using jQuery. The HTML structure consists of multiple departments with similar tags and classes: <div class="department_one"> <h1>Name Of Manufacturer</h1> < ...

How can you handle all HTML tags with Regex in a single line of code?

I've developed a PHP script that converts all inline CSS in HTML tags to classes. Visit the following link for more information: https://gist.github.com/iBars/aa52c6119e53908c91ac553aeba229e0 However, it currently only processes tags that are the onl ...

Deactivate button functionality in a PhoneGap app once it has been clicked

I am currently developing an iOS app using phonegap. I have a button on the screen that needs to be disabled after the user clicks it once. Despite my efforts to find a solution online, I cannot seem to get the javascript code I found to work in phonegap. ...

JS Emphasis on Scrolling Div

I'm facing an issue with a button that opens a scrollable div. When I try to use the arrow keys on the keyboard, they do not scroll the div as expected. Interestingly, if I click anywhere on the div, then I am able to scroll using the arrow keys. I ...

Troubleshooting Alignment Problems in Bootstrap 4 Tables

Having trouble aligning certain items. In thisFiddle, I have two options: Option1 and Option2. I want to align the toggle switches with the ones in the first two rows. Specifically, I want the toggle switches to be in the second column of the table and t ...

Can a Chrome extension display a webpage in a separate window using only JS, HTML, and CSS?

I am currently working on creating a custom Google Chrome extension. My goal is to have a small window appear when the user clicks on the extension button, without using window.open or traditional pop-ups, to display a specific web page. I have a basic un ...

Creating a popup with multiple tabs using CSS

Struggling to navigate through the intricacies of these code snippets <!DOCTYPE html> <html lang ="en"> <head> <style type="text/css"> a{ text-decoration:none; color:#333; } #pop{ width:557px; height:400px; background:#333; ...

Is it possible for a website administrator to view the modifications I have made to the CSS and HTML code?

Is it possible for a website to detect any temporary changes made to their CSS or Html through developer tools, even though these changes are not permanent? ...

Obtain checkbox input from HTML using Angular 2 typescript

Within my HTML code, I have defined two checkboxes in the following manner: <label><input type="checkbox" id="checkbox1" /> Folder 1: </label> <label><input type="checkbox" id="checkbox2" /> Folder 2: </label> I am fac ...

Having issues with jQuery's scroll to div functionality not working properly

With the click of a button, I aim to smoothly scroll down to a specific section. Initially, this section is hidden. There are two key actions that need to occur upon clicking the button: The section should become visible (this part is functioning co ...

Adding a directive to dynamically loaded HTML in Angular 5

Once the HTML has been loaded, I am able to choose any HTML element by utilizing ElementRef.nativeElement.querySelector(). Can you provide guidance on how to implement a directive on the selected element? ...

The art of creating dynamic divs with expand and collapse functionality through a loop

Looking for a way to enable my client to dynamically add additional divs to a form by simply clicking on a button (+), creating a loop-like effect. The loop should replicate the divs and the button to add even more divs, as shown in the image below. Any ...

Achieving a persistent footer at the bottom of the page within Material Angular's mat-sidenav-container while using the router-outlet

I am looking to keep my ngx-audio-player fixed at the bottom of the screen, similar to what you see on most music streaming websites. I currently have a structure with divs and various elements for dynamic content and playing music. The issue is that the ...

Entering text into a field / Inserting data into a MySQL database / Presenting

I am facing a challenge that I'm uncertain how to resolve. The issue lies with a textarea on my form that permits the user to input data in the following format: Windows XP Home and Professional<br />(32 and 64 bit) Windows 7 Home and Professi ...