Enable the modal window to be scrollable

I've been struggling with configuring my modal to allow scrolling when the content overflows. I attempted to add "overflow: auto" to the modal, but it didn't seem to do the trick. It's important to note that I am not utilizing Bootstrap. One thing I did was include CSS to prevent the background from scrolling when the modal is open, and I suspect this might be causing the issue with scrolling the modal itself. Below is the CSS snippet I'm currently using.

#modal-background {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-background-color);
    opacity: .50;
    -webkit-opacity: .5;
    -moz-opacity: .5;
    filter: alpha(opacity=50);
    z-index: 1000;
}

#modal-content {
    background-color: var(--modal-content-background-color);
    overflow: auto;
    border-radius: 10px;
    color: var(--modal-font-color);
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    box-shadow: 0 0 20px 0 #222;
    -webkit-box-shadow: 0 0 20px 0 #222;
    -moz-box-shadow: 0 0 20px 0 #222;
    display: none;
    height: auto;
    width: auto;
    left: 50%;
    margin: -120px 0 0 -160px;
    padding: 10px;
    position: fixed;
    top: 50%;
    z-index: 1000;
}

Any assistance on this matter would be highly appreciated. Many thanks in advance.

Answer №1

To create a scrolling effect for your content, simply define a specific value for the max-height property. Currently, you have set height to 'height: auto;', causing your modal to always attempt to fill the entire View Port's height.

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

The dimensions on Next.js pages exceed those of the viewport by a significant margin

I have recently encountered a perplexing issue where the dimensions of my webpage appear to be 2.7 times larger than the viewport, even when there is no content or styles applied. The strange part is that it seems as though the page has been scaled up, eve ...

Tips for including a background image using the :after pseudo-element in Angular 2

I'm facing a challenge with passing a URL image from my HTML to my CSS in Angular, and I can't seem to figure it out: Here is a snippet of my CSS: card-profile_visual { height: $visual-height; overflow: hidden; position: relat ...

"Deleting a line from a text file in PHP with a predetermined format: A step-by-step guide

I am facing a situation where I need to manipulate a CSS file through PHP. The CSS file contains the following properties: #firstdiv { width:100%; height:200px; } #seconddiv { width:80%; height:70px; } #thirddiv { width:80%; height:70px; } #firstdiv { col ...

An External Force is Disrupting My Jquery

Something seems off because everything was working perfectly fine until the FallingLeavesChristmas.min.js file stopped activating on this specific page. I initially thought it was an issue with the JavaScript itself, but that doesn't seem to be the ca ...

Is it possible to use an onclick function to input JavaScript values into a password entry box seamlessly?

Is there a way to input password values continuously using a JavaScript onclick function into a password field? I have two images, one 'Blue' and one 'Red', that trigger an onclick function with the following values: Blue= w3! Red= T4 ...

My Ionic app displays a blank nested view

Below are the route configurations in app.js: .state('signup', { url: '/signup', templateUrl: 'templates/signup.html', controller: 'signupCtrl' }) .state('profile', { url: ' ...

What is the best way to style multiple classes within the same element (specifically an ordered list ol

Using CSS counters, I have created various styles for an ordered list <ol> by applying different classes and adjusting the styles accordingly. Now, I want the counters to adjust based on screen size, displaying smaller numbers on smaller screens. To ...

CSS hover effect applied uniformly to all link children

Here is the HTML code snippet I am working with: <a href="">Bioshock 2<span> - Xbox 360 review</span></a> My goal is to style the first part of the link differently from the span. The desired styling should look like this: https: ...

Maximizing the potential of Bootstrap slider within OpenCart

Has anyone attempted to use Bootstrap slide with the Opencart slideshow module? Here is my code, but I am getting all active classes. Can someone please help me with this? <div id="carousel-example-generic" class="carousel slide" data-ride="carousel"& ...

Update dynamically generated CSS automatically

Is there a way to dynamically change the CSS? The problem I'm facing is that the CSS is generated by the framework itself, making it impossible for me to declare or modify it. Here's the scenario at runtime: https://i.sstatic.net/IovGr.png I a ...

Struggling with getting the JavaScript, scss, and CSS television animation to turn on and off properly? Seeking assistance to troubleshoot this

After finding this javascript code on Codepen and seeing that it worked perfectly in the console there, I tried to run it on my computer with jQuery but it didn't work outside of Codepen. Even when attempting to use it on JSfiddle or compile the SCSS ...

What's the best way to rotate an SVG <use> element around its center point?

Utilizing an SVG within another SVG, I am trying to manipulate the rotation of the <use> element in the SVG around its own center. I have attempted to use tips from a previous question to set the transform-origin and transform-box properties in the ...

Flame-inspired CSS editor

My current CSS editing workflow goes something like this: I ask for feedback on a page Suggestions are given to make post titles bigger I use Firebug to inspect the post title element I locate the corresponding CSS statement in Firebug (like h2.post_title ...

Looking to include a toggle button in the menu for both desktop and mobile versions using Bootstrap

When viewing the website on a mobile device, the menu appears as a toggle button. However, on desktop, the menu is displayed without the toggle. Is there a way to show the menu in a toggle button on the desktop version using Bootstrap? ...

Ways to remove content that exceeds the boundaries of a div element

I am facing a challenge with a parent div that has a specified size. Inside this parent div, there are other child divs, and if any of those child divs start displaying their content outside of the parent div, I want to completely remove that div. I do not ...

Malfunction detected in JavaScript shopping cart functionality

Trying to implement a functional shopping cart on a webpage has been a challenge for me. I've encountered issues in my JavaScript code that are preventing the cart from working as intended. As a newbie to JavaScript, I'm struggling to pinpoint th ...

Adjust the width of individual columns in Bootstrap 4 responsive tables to ensure they have specific widths

I am currently working on setting up a table where specific columns require a fixed width and do not adjust automatically. Despite attempting a method to achieve this, I have encountered issues as the width still adjusts based on the length of the text. ...

Adjusting the margins of jQuery mobile buttons

I seem to be stuck on a simple error that is causing me to spin my wheels. Take a look at the following jqm (version 1.3) view (in haml) #main-header{'data-role' => 'header'} #main-content{'data-role' => 'content ...

The CSS property that controls the background color of an element

This syntax for a CSS background property is quite effective: .my-element { background: linear-gradient(rgba(131,131,131,0.8), rgba(98,98,98,0.8)), url('img/background.jpg') } However, I am not looking for a gr ...

Bootstrap 4 allows for the use of the d-lg-flex class to create a flexible column layout

I'm facing an issue with my table on smaller screens where some columns need to be hidden. Here's the code snippet I'm using: <table> <tr> <td>Normal 1</td> <td class="d-lg-flex d-none">hidden 1</t ...