adjustable height, complete height backdrop

I would like to expand the background-color: rgba(0, 0, 0, 0.5) of <div id="overlay"></div> to cover the entire height of the screen.<div id="overlay"></div> when clicked on with the class 'overlay'. However, the height does not extend to full height when there are multiple joke blocks displayed. The issue occurs specifically in the media screen range of 820px-1280px (https://i.sstatic.net/4i63WcLj.png) (https://i.sstatic.net/lGSkyjS9.png) I have attempted setting body {height: 100vh or 100%} and also tried .overlay{min-height:100vh or 100%}. Unfortunately, when the horizontal scroll appears, neither the body nor overlay stretch properly.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Chuck Norris Jokes</title>
</head>
<body>
<div id="overlay"></div>
        <div class="main_wrapper " id="mainWrapper">    
        <div class="content_wrapper">
                <header class="header" id="header">
                </header>
                <div class="title_wrapper" id="titleWrapper">
                
                </div>
                <div class="form_wrapper" id="formWrapper">
                </div>
                <div class="jokes_wrapper" id="jokesWrapper"> 
                </div>
        </div>   
        </div>
        <div class="sidebar hide" id="sideBar">
           
            <h3 class="sidebar_title">Favorite</h3>
            <div class="favorite_jokes_wrapper" id="favJokesWrap">
            </div>
        </div>
</body>
</html>

body,html{ @apply min-h-screen; overflow: auto;

}

.main_wrapper{ @apply p-5 overflow-auto container min-h-full m-auto w-full relative md:m-auto md:p-2 md:pt-5 xl:max-w-[960px] xl:m-0; .content_wrapper{ @apply xl:max-w-[600px] xl:m-auto }

}; 
.overlay{ @apply w-full absolute top-0  left-[-32px] bottom-0 right-0 min-h-full pointer-events-auto ;
z-index: 2;
background-color: rgba(0, 0, 0, 0.5);}

.sidebar{ @apply container bg-light_grey absolute z-10 top-0 min-h-screen right-0 md:w-[56%] xl:block max-w-[480px];}



.sidebar_title{
    @apply hidden xl:block xl:m-10 font-medium text-xl text-sub_main_color;
}
.favorite_jokes_wrapper{
    
    @apply flex flex-col mt-16 items-center justify-center min-h-full bg-light_grey xl:mt-5;
    .joke {
            @apply bg-white rounded-xl gap-5 md:pt-12 md:px-5 md:pb-5;  
            border: 1px solid #F8F8F8;
            box-shadow: 0px 4px 6px 0px #0000001A;
            div{
                @apply md:w-[298px];
            }
            p {
                @apply text-sm font-normal;
            }
            h3{
                @apply mt-0 bg-light_grey mt-2 text-10px ;
            }
     }
} `

Answer №1

Explanation: The reason for this behavior is that when using 100vh, it means 100% of the viewport height. Therefore, as you scroll, the overlay's height remains constant and moves along with the main_wrapper content. To avoid this issue, consider fixing the position of the overlay to the left side of the screen so it stays in place.

A simple solution is to change the positioning from absolute to fixed

Reference: https://i.sstatic.net/o5KEiQA4.png

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

Issue with Bootstrap Modal failing to display the dialog box

I have been attempting to incorporate a Bootstrap Modal for quite some time now. Despite following the guidelines in the bootstrap documentation, I am still unable to get it to work properly. Any ideas why this jsfiddle link is not functioning as expected? ...

Ways to align the navbar-brand at the center using bootstrap

I have attempted multiple techniques such as flex boxes, auto margins, and transforms to center this navbar-brand element on the page. However, it continues to align between the right side and a button. I want it to disregard the button positioning and ins ...

Modifying the appearance and behavior of an element dynamically as the page is being loaded using AngularJS

Struggling with a challenge for two days now, I have attempted to implement a panel-box using bootstrap and AngularJS. Within the confines of a controller, my code looks like this: <div id="menu2a"> <div class="panel list-group"> <div ...

Strange occurrences observed with the interaction of multiple CSS classes

Recently, I encountered a situation with a class that had me puzzled. .lifetime .containerrow { text-align: center; height: 20px; } To enhance the appearance of certain elements by making their text bold, I attempted the following: .lifetime .co ...

Creating responsive text styles in CSS

I'm encountering an issue with a button that says Upgrade my account. My goal is to have different text for screens smaller than 990px, where it should display just Upgrade due to length constraints. Is there a CSS solution to achieve this without h ...

Tips for styling an image and vCard within a Foundation accordion menu

I am working on a project that involves creating a list using an accordion feature to display names of individuals. When a user clicks on a person, I want the dropdown content to show their image and vcard details. How can I structure the content so that ...

To center a div vertically within a Bootstrap 4.1 container-fluid > row > col, you can use the following method

I'm currently working on incorporating Bootstrap 4.1's align-middle into a col nested within a row. Despite my efforts, the content within is not aligning to the middle as expected. Take a look at my code below: <body class="d-flex"> < ...

ASP.net is failing to run jQuery's .toggleClass() function

Let's say we have this jQuery code snippet: $("#saveButtonFull").on("click", function () { $(".inner").toggleClass("progressBar"); $(".save").toggleClass('textColorize').html("Saved"); }); This code produces a filling animation on ...

Completed Animation with Callback in AngularJS CSS

Currently working with AngularJS and hoping to receive a notification upon completion of an animation. I am aware that this can be achieved with javascript animations such as myApp.animation(...), but I'm intrigued if there is an alternative method wi ...

Designing divs that intersect

Struggling to replicate a design due to issues with the overlay section. I have separate divs for the menu bar, globe, and header text but positioning them as overlays is proving problematic. Attempted to use zIndex without success. https://i.sstatic.net/ ...

Customize the website's CSS for optimal viewing on an iPad

I have a website with two CSS files: one for viewing the site on a desktop screen and the other for viewing it on an iPad screen. Despite having the same HTML code, is there a way to detect the iPad device and force it to use the appropriate CSS file? Tha ...

Stop a div at a specific point with this unique jQuery plugin

I am looking to implement a similar feature on my website that can be seen here: The desired functionality is when a link stops at a certain point while scrolling, and upon clicking the link it smoothly scrolls to a designated div. Additionally, as you sc ...

What could be causing the CSS transition to fail when the menu button is clicked?

After clicking on the menu, a class 'active' is added to both the 'div' and 'section' elements. https://i.stack.imgur.com/jbamR.png The following javascript code accomplishes the above functionality: <script> const ...

Navigate between tabs with a single click

Hey there! I'm having trouble putting together a webpage that features a sidebar. I want to make it so that clicking on one of the links at the top will switch the tab and its content accordingly. However, the current code I have isn't working an ...

When attempting to overlay CSS text onto an image, the text appears to be hiding behind the

Essentially, what I was attempting to do was overlay some text on top of an image on a website I'm creating. After researching online, I learned that I could achieve this by using position absolute and relative, which worked to some extent. However, n ...

The Bootstrap table spills over the edges of the container

I'm currently working on a project where I need to create a table with a grey background, but I am facing an issue where the lines from my table are extending past the div container. I even tried placing it inside a form, but that did not resolve the ...

Tips on creating a repeating background image with CSS for a sprite

I'm facing a challenge that I can't seem to solve - I need to set a sprite as the background for a container. The issue is that despite my efforts, I haven't been able to achieve this. I've searched extensively but couldn't find a ...

Creating a drop-down menu within an HTML table along with a D3 bar chart

How can I implement a drop-down menu allowing the user to choose a time interval for this HTML table and d3 bar chart? The time intervals needed are: Now, 24 hours, 48 hours, 72 hours, 1 week, and 1 month. I am relatively new to creating dynamic tables and ...

Tips for enhancing the clarity of elements in KineticJS

I'm new to using Kinetic JS, and while I think it's a great library, I'm having trouble with the resolution of the elements. I know that Kinetic JS doesn't use SVG, but the resolution is not up to par. I'm creating circles and othe ...

Challenges with text wrapping in a continuously scrolling container in CSS

I am currently developing a project that requires infinite horizontal scrolling for cells containing thumbnails and text. While most of the functionality is in place, I am facing an issue with text wrapping. The CSS and HTML code are provided below. The fi ...