The container div contains a pop-up that expands the height of the container, rather than overlapping on top

I am currently developing a grid system similar to Excel, but I am encountering issues with displaying pop-ups properly as the lower part gets cut off by the container div.

This problem is reminiscent of a situation discussed in a Stack Overflow post titled CSS: How to have position:absolute div inside a position:relative div not be cropped by an overflow:hidden on a container, and I am seeking a solution that can provide similar results within a containing div. Achieving the desired layout without using the viewport has proven challenging.

The structure and styling of my setup are as follows:

<body>
    <div class="viewport">
        <div class="canvas">
            <div class="rows">
                <div class="row">
                    <div class="cell">
                        <div class="cell__Value">
                            <div>
                                <div class="popup">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

.viewport {
    height: 150px;
    width: 400px;
    background-color: blue;
    overflow: hidden;
    position: absolute;
    top: 35px;
}

.canvas {
    height: 149px;
    width: 399px;
    background-color: lightblue;
    overflow-y: scroll;
    overflow-x: auto;
    position: absolute;
}

.rows {
    height: 100px;
    width: 700px;
    background-color: red;
    overflow: hidden;
}

.row {
    background-color: darkred;
    height: 35px;
    overflow: hidden;
}

.cell {
    background-color: green;
    position: absolute;
    left: 100px;
    width: 100px;
    height: 35px;
    overflow: visible;
}

.popup {
    background-color: lightgreen;
    opacity: 0.8;
    position: relative;
    width: 150px;
    height: 200px;
}

To visualize this issue, I have set up a simulated scenario on jsFiddle - http://jsfiddle.net/huf45f2h/2/, but unfortunately, it does not function correctly either.

In essence, the goal is to allow y-overflow scrolling within the canvas so that the rows in the grid are scrollable without occupying the entire page. The pop-up in the fiddle serves as an informational element meant to appear upon clicking a single cell. However, as demonstrated in the mock example, when the pop-up's size is large, both the viewport and canvas start scrolling instead of positioning the pop-up partially outside the viewport.

Various recommendations from resources like have been attempted without success. Strategies such as floating the pop-up and adjusting the z-index were explored as well.

What steps can be taken to resolve this issue and ensure the pop-up displays as intended?

Answer №1

It seems like I comprehend the issue you're facing, and fortunately, the solution appears to be quite simple.

All you need to do is assign a fixed position to the element, which will ensure it stays on top of other content. This method is commonly used for creating popups.

.popup {
background-color: lightblue;
opacity: 0.7;
position: fixed;
width: 200px;
height: 250px;}

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

Switch the hue of "BRANDS"

I have a website at the following link: My goal is to change the text color of "Nike" to white. If you decide to alter this text and modify the product name, please let me know so we can discuss it further. a { color: #F7F6F6; text-decoration: non ...

Is the <ul> tag aligning to the left?

I recently encountered an issue while designing my website. I created a div with a width of 200px on the right side of the webpage, and added a list of links within it. However, I noticed that elements inside the div are aligning slightly to the left, givi ...

Simple Steps for Dynamically Adjusting Table Cells without Disturbing Existing Data

Is there a way to make a table automatically arrange cells in rows of two, adjusting as necessary when adding or removing cells (with one cell in the last row if there is an odd number of total cells)? For example: <table> <tr> <td>o ...

Creating a unique slider using CSS animations and JavaScript

After hours of research, I have hit a roadblock with my custom slider project. I am reaching out to fellow developers for help and hoping that my experience can benefit others facing a similar challenge. The goal is to create a custom slider with animated ...

Creating a function that generates a random number of <div> elements and places them inside a <li> element is a great way to dynamically add

Hey there! I could really use your assistance with this. I am trying to dynamically generate a list of items, but instead of placing each item in a separate <li>, I would like to achieve the following structure: <ul> <li> <di ...

Is there a way to customize CKEditor to prevent it from continuously adding <p></p> tags within the textarea automatically?

As I was going through the CKEditor tutorial, I implemented the following: $( '#editor' ).ckeditor(function(){}); //it's working great!! However, after submitting the form, I noticed that by default, the textarea displays <p></p ...

Switching the Vue image on Routerlink's isExactActive feature

Is there a way to display different images based on whether a link is active or not? <router-link to="/"> <img src=" :active = isExactActive ? pic_active.png : pic_inactive.png}}" /> //Something along these lines ...

Implementing the Fixed Header feature in DataTables - A Step-by-Step Guide

I'm encountering an issue with implementing a fixed header for my table using the DataTables plugin. Despite previously asked questions addressing similar problems, I am still unable to resolve it. I suspect that conflicting CSS or missing CDN links c ...

Inserting an image into a <div> means adding a reduced-size image numerous times to fill the Div

I have encountered an issue while using the code provided in the CodePen link below to paste an image into a Div. The problem is that when I paste a small image, it shows up multiple times within the Div if clicked on after pasting. My goal is to display t ...

A guide to determining word frequency in a sentence's SQL with PHP and HTML

When a sentence is provided by the user as input, it is then broken down into individual words and organized into an array. Following this, the goal is to pass this array (depending on the number of words in the sentence) to a SQL query that will analyze ...

The ASP Classic site is not displaying the expected styles on its elements

Currently, I am revamping an ASP Classic website. The entire site relies on a major CSS file named Main which houses all the styles used. In this file, there are not many styles as the current design is quite basic. Some elements on certain pages have thei ...

Sending a div class as a parameter to a JavaScript function

Wondering if it's possible to pass a div's class into a JavaScript function. I'm using SquareSpace so adding an id to the div is not an option, but it works fine with divs that have ids. JQuery is already loaded. This is my current train of ...

Incorporating live text into a tag while arranging items by price in both ascending and descending order

I recently added a button to my online shop that allows users to sort products by price, even though I don't fully understand the underlying JavaScript code. I want to enhance this button by updating the text to indicate whether the sorting order is ...

The Percentage Value for Height in CSS is Unresponsive on Android Application Interface

I am currently working on an app that displays screen content in HTML format, which is pulled from a database. To ensure compatibility with various devices, I need to use percentages for the width and height of the elements. However, I have been facing iss ...

Unique hover effects for tab navigation

I have designed my website with 4 tabs on the homepage: holidays, hospitality, events, and consulting. I am trying to create an effect where hovering over the tabs displays images. Here is the code I have tried: HTML: <div class="menu_links"> & ...

Manipulate images in real-time and insert custom text using JavaScript/jQuery

Within my possession is an image depicted above. My objective revolves around dynamically altering the values present at the occurrences of L, A, and B; to achieve this, I must eliminate or conceal L, A, and B while substituting them with numerical equiv ...

Customizing the Dropdown Arrow Icon to a Desired Icon of Choice

I'm looking to customize the dropdown select on my website by changing the arrow icon to a plus icon, which will then turn into a minus icon when clicked and the choices are displayed. I'm new to jquery and eager to learn more about this language ...

Is it possible to dynamically change HTML content by utilizing a JSON file?

Looking to implement a JavaScript loop (using jQuery) that can dynamically populate the HTML file with content from a JSON file based on matching <div> ids to the JSON "id" values. The solution should be scalable and able to handle any number of < ...

"Understanding the impact of CSS margin on elements nested within a container with position

I find myself in a tricky situation right now. To make things easier, I'll show you what I've created and highlight the issue, rather than explaining it all. I've been on the hunt for a solution for quite some time, to no avail. If you vis ...

Customize Color of Specific Options in MaterializeCSS

I am currently utilizing a select dropdown feature from the MaterializeCSS library. My goal is to implement a specific class that will change the text color of certain options within the dropdown. Is there a method available for accomplishing this? Upon r ...