Avoid the div from covering the scrollbar within its containing parent div

Background: Trying to resolve an issue mentioned here: https://github.com/likeastore/ngDialog/issues/94

Challenge: If you open this plnkr link: http://plnkr.co/edit/qKJiNwyivqJVCAtyhwYR?p=preview and attempt to hold and drag the scrollbar with the mouse, you'll notice that the scrollbar on the parent container is unresponsive. The issue seems to be caused by the position:fixed div.overlay overlapping with the scrollbar of its parent container.

HTML Structure:

<div class="container">
  <div class="overlay"></div>
  <div class="content">
    <div>I'm large 1</div>
    <div>I'm large</div>
    <div>I'm large</div>
    <div>I'm large</div>
    <div>I'm large</div>
  </div>
</div>

CSS Styling:

.container{
    position: fixed;
    overflow: auto;
    z-index: 10000;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;  
    padding: 160px;
}

.container .overlay{
    position: fixed;
    background: rgba(0, 0, 0, 0.4);
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

.container .content{
    background: #f0f0f0;
    border-radius: 5px;
    max-width: 100%;
    position: relative;
}

Answer №1

In my opinion, it would be beneficial to modify the HTML structure as follows:

<div class="overlay"></div>
<div class="container">
  <div class="content">
  </div>
</div>
</div>

Remember to adjust the corresponding CSS styles. http://plnkr.co/edit/QsQBk5oJfWuCymBwUtYB?p=preview

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

There seems to be a glitch with certain div elements not behaving as expected in Bootstrap version

I've been struggling with a persistent question lately that seems like it should have a simple solution, but I just can't seem to figure it out. The issue I'm facing is related to Chrome and how certain divs on this particular page behave ...

Why does the text in a div display in Safari 8.2 and Chrome 39, but not in Firefox 34?

In my HTML document, I have a div tag located within the body like so: <div id="content_text"></div>​ Using javascript, I later set the contents of the div like this: var content_text = document.getElementById("content_text") c ...

Unresolved issue with AngularJS radio button binding

As a beginner in using Angular.js, I encountered an issue with data binding when dealing with radio buttons. The HTML code in question is: <label class="options_box" ng-repeat="item in item_config_list.item_config"> <input type="radio" name ...

What happens when there is a 1-second delay in loading CSS on an HTML page?

Lately, I've been working on creating HTML and CSS pages. However, whenever I load a page, I notice that there's always a brief half-second flash of the HTML content without any styling applied. Does anyone have an idea why this is happening and ...

What is causing the issue with my CSS keyframe animation not functioning correctly when using `animation-direction: reverse`?

Exploring the use of animation-direction: reverse to streamline my CSS keyframe animation process. An interesting scenario arises when a container div is clicked, toggling an "active" class using jQuery to trigger the animation in either forward or backwar ...

AngularJS is a highly intuitive platform that incorporates Google Maps for

I am relatively new to using Angular and decided to experiment with integrating Google Maps into my project. Here's what I need: I have a search bar for finding restaurants. The API returns the address, latitude, and longitude of the restaurant searc ...

Achieve a full-height sidebar design similar to Wordpress using flexbox functionality

Working on a web app that features a tools sidebar with a fixed width requirement amidst fluid content. Explored using flexbox to achieve this, but encountered an issue where the main box only takes the height of the viewport instead of the entire site&ap ...

Tips for incorporating images into AngularJS applications

Just starting out with angular js. I've run into an issue. I'm working with a json for my data and I'm unsure about how to incorporate images into my code <div ng-controller="myCtrl" class="container"> <div class="col-md-8"&g ...

jQuery's ajax request is functioning properly, while the AngularJS ajax request is not executing as expected

Currently, I am in the process of learning AngularJS and attempting to construct a front-end system that retrieves data from Wordpress. Everything seems to be properly configured on the back-end side, as I can successfully retrieve the data using a jQuery ...

Several iFrames embedded on the website automatically adjust to the same pre-set height

Apologies if this question has already been addressed, but I am struggling to properly articulate it. Here's the issue: I have a client's holiday accommodation website that uses three embedded iFrames for a Calendar, Booking Enquiry, and floorpla ...

Attempting to design a button with an arrow icon

I need help creating a button with an arrow similar to the image below: https://i.sstatic.net/aJp7B.png However, my current code is producing a button that looks like this: https://i.sstatic.net/tuHvT.png This is my code snippet: .ms-btn, .ms-btn: ...

How can I display the updated save button text in an Angular form?

Using an Angular 1 form to display a changed save button text can be achieved with the following settings: (disabled) save - displayed when the form is initial (enable) save - displayed when the form is edited or re-edited after being saved (enable) save ...

Display a dropdown list using ng-repeat to prevent selecting the same value multiple times

Within my ng-repeat loop, I have a drop-down menu and an add button that allows users to add new drop-down menus to the list. However, I am looking for a way to restrict the second drop-down menu from selecting the same value as the first one. In other wor ...

Is there a way to transform a local array into remote JSON data?

I am attempting to retrieve an array from a remote server that is connected to a dynamic database. From what I have gathered on Ionic forums, it seems that I need to utilize the $http function from AngularJS. However, since I am new to AngularJS, the curr ...

Center the input field both vertically and horizontally within an overlay

When the user clicks on the search icon, I want to display the search field as an overlay. Currently, the overlay is working but the search input field is appearing in the middle vertically. Check out the Fiddle <a href="#overlay" id="open-overlay"&g ...

Is it possible to apply styling to an element based on the position property of its ancestors using only CSS?

Wondering if it's possible to style an element based on its ancestors' CSS property value. Consider the HTML snippet below: <div><!-- ancestor --> <!-- Any number of descendant levels before reaching the target div --> < ...

Ways to modify the header dimensions using CSS

I've been trying to figure this out, but I can't find a solution. For the structure, I'd like to use an h2 header to make it more semantic, but I want it to appear as an h5 header visually. However, CSS is not cooperating with this idea an ...

Insert Authentication Token Post AJAX Request

Currently, I am developing a web application using Angular.JS and Node.JS for the back-end. When it comes to the login page, an AJAX call is utilized to handle the login process. Upon a successful login attempt, my goal is to redirect the user's brow ...

The height of the logo is not the same as the height of the menu

Seeking assistance with aligning a logo next to the navigation menu on my website. Despite my attempts to adjust margins and paddings, the logo and menu appear to be misaligned. As a beginner in CSS, any guidance or tips would be highly appreciated! https ...

Steps for converting a Calendar into a JSON format

I am working on developing a REST application like the one shown below: @XmlRootElement @Entity @Table(name = "tb_verarq") public class Verificacao implements Serializable{ private static final long serialVersionUID = 1L; @Id @GeneratedValue ...