Overlay effect experiencing issues with opacity

I am having trouble creating a popup overlay with an opaque blue layer that hides the red background beneath.

<a href="www.google.com">hi</a>
<div class="dim">
    <div class="test">
        <div> test </div>
        <div> 2nd </div>        
    </div>
</div>​

.dim {
    height:100%;
    width:100%;
    position:fixed;
    left:0;
    top:0;
    background-color:red;
    opacity: 0.5;
}

.test {
    opacity: 1.0;
    border: solid;
    display: inline-block;
    background-color:blue;
    position: fixed;
    top: 50%;
    left: 50%;
    margin-top: -10px;
    margin-left: -10px;
}

Jsfiddle link

Answer №1

Make sure to format your HTML properly -

<a href="www.google.com">hi</a>
<div class="dim">   
</div>
<div class="test">
    <div> test </div>
    <div> 2nd </div>        
</div>

Check Out the Updated Fiddle Here!

Answer №2

To easily resolve this issue, you can simply move the .dim class outside of the .test class by copying and pasting.

For a visual example, check out this link: http://example.com/jsfiddle

Here is the code transformation:

<a href="www.google.com">hi</a>
<div class="dim">

</div>
<div class="test">
    <div> test </div>
    <div> 2nd </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

Creating a Centered Masonry Layout with CSS

Recently, I designed a masonry layout with CSS grid. I had a specific requirement for this layout - it needed to have a maximum of 8 columns and also be responsive based on the screen size. Initially, everything worked perfectly until the number of items ...

The webpage appears to be operating smoothly when tested locally and on JSFiddle, however it is encountering

Just joined and brand new to this game. Completed a course at work over the last few weeks, and I must say, I'm really enjoying it. However, when I tried to create a page using Bootstrap styling and added an accordion and a carousel, both features fai ...

Adjust the size of the Vimeo video to fit the container dimensions and eliminate any black bars

Is there a way to eliminate the black bars that are present in the vimeo video which has been embedded? Below is the link to the code snippet. JSFiddle Link <div class="embed-container"> <iframe src="https://player.vimeo.com/video/86019637?title= ...

Is there a way to make the text overflow to the left of my input field?

I have a dynamic input field with text that exceeds its display width. By default, only the beginning of the string is visible, while the end remains hidden. <input type="text" value="abcdefghijklmnopqrstuvwxyz" style="width: 25%; font-size: 25px; ma ...

Position the personalized radio button to be in line with the first choice text

I frequently update this section with a new Jsfidle link to demonstrate the issue when the max-width is set to 300px. For responsive design, adding the "span" tag before radio buttons helps align input content with custom checkbox backgrounds. To see the ...

Styling with CSS to create a tab in the shape of a

Is it possible to turn the square at the bottom of my tab into a small arrow pointing downwards instead of an image? The javascript may not be functioning on this specific site, but it works fine on my website. How can I achieve the effect of having a sma ...

Columns that adapt to different screen sizes while maintaining a fixed aspect ratio, limited to a maximum of two columns

I'm facing a challenge trying to blend a few elements together: My goal is to have two columns take up 100% of the browser width with a height that adjusts relative to this width. I want these columns to switch to one column when the viewport is sma ...

Although IE may have issues, @font-face is not functioning properly in Chrome and FireFox

Hello, I've encountered an issue with implementing @font-face in CSS. It seems to be working properly in Internet Explorer, but it has no effect in FireFox and Chrome. I am trying to add a custom font to my website by placing the files Snazanin.ttf an ...

Issues with the use of overflow:hidden

I need to create 5 divs aligned horizontally next to each other, spanning the width and height of the window. Each div should occupy 20% of the window width, and any overflow content should be hidden. Below is the CSS code for two of the divs: #container1 ...

Automatically determining the optimal quality from various sources tailored to the individual user - jwplayer

Check out the code snippet below: var playerInstance = jwplayer("mySingleVideoWrapper").setup({ image: getCurrentPosterSrc, sources: [ { file: 'file-360.mp4', label: "360p" ...

Preventing Scrollable Div Content from Displaying Behind a Fixed Div using CSS

Seeking help with a message_container division that contains a fixed scrollable message_header division and a scrollable message_body division. The issue I am facing is that the content of the message_body division is appearing behind the fixed div. How ca ...

JSP not able to render CSS properly

Trying to apply some basic CSS to my JSP page. The JSP is located at WebContent > WEB-INF > pages > Login.jsp, while the CSS file is at WebContent > WEB-INF > css > Login.css. Below is my JSP code: <head> <link rel="stylesheet" ...

What are some ways to keep text within the boundaries of a div element?

I have tried multiple solutions for this issue, but none seem to be working for me. When I append a paragraph to a div, the text extends beyond the element. Below is the code I am using. Any assistance would be greatly appreciated. CSS: .chat-h { margi ...

Resize a circle upon hovering while keeping the same thickness of the border

I'm working on creating a circle with just a border (no background) that scales on hover. Here's the code I have so far: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <link type="text/css" rel="stylesh ...

Sticky footer in Bootstrap causing content to overlap

I'm a beginner when it comes to Bootstrap, and I'm attempting to integrate it with Symfony2. I currently have a sticky top bar in place for navigation purposes. However, I'm facing an issue when I try to add a similar sticky footer at the bo ...

The entire page is filled by the image link block

I created a primary div to serve as a container with a width set to 90%. At the top of this div, I have a title (image) with styling attributes such as height: 5em, display: block, and margin: auto. In my HTML structure, it is organized like this: <a h ...

Adjust text size automatically to fit into a container with a fixed size

Looking to dynamically adjust the font size of user-entered text to fit within a fixed-size div. The goal is to have the text fill the box as much as possible. For example, if the div is 400px x 300px and the user enters "ABC", the font will be very large ...

Get Your Business Rolling with the Shopify Cruise Theme

I'm currently utilizing the ride theme on my Shopify website and I've embedded a video in an index.json file: "video_url": "https:\/\/www.youtube.com\/watch?v=KlxiEKrhWIQ", Is there a way to make the video aut ...

Is there a way to locate the final <li></li> within each <ul></ul>? (Regarding front-end development, specifically dealing with html, css, and jquery)

I'm dealing with a menu that has submenus of its own. Issue: Upon loading the page, I notice that the website is adding an extra letter S at the end of each submenu. How can I eliminate that letter S from the end of every submenu using JQuery or CS ...

Guide to locating the index of a div element that has been dropped onto a droppable div

My web application features drag and drop functionality allowing users to drag a div and dynamically drop it onto a droppable area. Additionally, the droppable area has sortable functionality enabled. Now, I need to determine the indexing in order to acc ...