Display scroll bars over the position:absolute header

My container has content that exceeds its size in both directions. To see the issue, try scrolling horizontally and vertically on the table available here:

The vertical scrollbar is visible as desired, except that it gets hidden behind the table header until you scroll down a bit.

As for the horizontal scrollbar, it only becomes visible when you reach the bottom, and then it behaves similarly to the vertical scrollbar (hiding behind the sticky column).

The reason for this behavior is clear: Both the sticky header and column have a position: absolute property and a higher z-index than the overflowing main content div.

I want both scrollbars to be constantly visible and above the sticky headers. While I doubt CSS can achieve this, there might be a solution using JS and a library like this one: https://github.com/malte-wessel/react-custom-scrollbars

The basic structure of the table is:

<div style="position: relative; overflow: hidden;">
  <div style="position: absolute; z-index: 2;">Header</div>

  <div style="position: relative; overflow-y: auto; width: 100%;">
    <div style="position:absolute; z-index: 1;">Column</div>

    <div style="overflow-x: auto; height: 100%;">
       <div>Content that overflows in both directions</div>
    </div>
  </div>
</div>

How can I achieve this effect?

Answer №1

This new arrangement could potentially simplify things for you and help achieve your desired outcome by reducing nesting layers and utilizing margins.

<div style="position: relative; overflow: hidden;">

  <div style="position: relative; overflow: auto; width: 100%;">
    <div style="position: absolute; z-index: 2;">Header</div>
    <div style="position:absolute; z-index: 1;">Column</div>

    <div style="margin: header-size 0px 0px cell-size;" height: 100%;">
       <div>Content that overflows in both directions</div>
    </div>
  </div>
</div>

If necessary, perhaps you could utilize JavaScript to adjust the header's width dynamically when content becomes scrollable to address any issues with the vertical scrollbar being obscured. Unfortunately, there may not be a straightforward solution for handling the horizontal scrollbar in the current format, as the scrolling containers differ between the x and y directions.

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

Unable to locate the necessary file. Specifically looking for index.html within a react application set up with Docker Compose

Having set up my react application using create-react-app, I attempted to run it with Docker container and Docker compose. However, upon running it with Docker compose, I encountered the following error: web_1 | Could not find a required file. web_1 ...

Utilizing pure CSS to target the first and last classes

I want to use pure CSS to select only the first and last classes throughout the entire document. In my scenario, the structure looks like this: <div class="Container"> <div> <div class="Parent"></div> <pre> ...

Sleek transition-ready zoom functionality for THREE JS with clickable controls

Hey there, I've been attempting to animate a transition between scenes in THREE js for quite some time now. I have successfully cleared the scene and recreated the next one, but the transition between them is proving to be quite challenging. I have cr ...

What is the best method for expanding the width of a <rect> element with animateTransform?

How can I make a <rect> in SVG expand its width using animateTransform based on a specified value? Additionally, I want the color of the <rect> to change according to the following conditions: If the <rect> value is between 0 and 29: {f ...

Efficiently update numerous users simultaneously within Firebase

I am trying to figure out how to update multiple user objects stored in my Firebase 2.x DB simultaneously. Each object is structured similarly to the following example: { "users": { "$id": { "date_of_birth": "June 23, 1912", "full_name": ...

Arranging two classes in close proximity

I need help aligning two classes that are stacked on top of each other to be displayed side by side. Below is a screenshot of the two classes: https://i.sstatic.net/V0tLL.png The right class is .testm_boxes1, and the left class is .testm_boxes2. Here is ...

Obtaining localStream for muting microphone during SIP.js call reception

My approach to muting the microphone involves using a mediastream obtained through the sessionDescriptionHandler's userMedia event. session.sessionDescriptionHandler.on('userMedia', onUserMediaObtained.bind(this)) function onUserMediaObta ...

Save and retrieve documents within an electron application

Currently, I am developing an application that will need to download image files (jpg/png) from the web via API during its initial run. These files will then be stored locally so that users can access them without requiring an internet connection in the fu ...

Is it possible to disable the save option on a PDF popup window?

When displaying a PDF using an embed tag, I have managed to disable print and content copying through document properties. However, I am struggling to find a solution to disable the save option that pops up. Is there a way to achieve this using JavaScrip ...

Using JavaScript functions within PHP is not supported

Currently, I am utilizing Laravel for my backend operations. Within my setup, there exists a JavaScript function called StartJob() that facilitates Google crawling. In the scenario where I input a keyword, which is then cross-referenced with the database, ...

Angular Application for Attaching Files to SOAP Service

I am currently utilizing soap services to pass XML data along with file attachments. While SoapUI tool works perfectly for this purpose, I want to achieve the same functionality through Angular6 in my project. Below is a snippet of my Xml code. <soap ...

Guide on encrypting data on the server with PHP and decrypting it on the client side using JavaScript

I'm currently developing a training website with PHP and I am looking to share my training resources securely without worrying about copyright issues. My plan is to encrypt the documents on the server before sending them, and then have them decrypted ...

Unable to get jQuery click and hide functions to function properly

Hello, I am currently working on a program where clicking a specific div should hide its own class and display another one. However, the code does not seem to be functioning correctly. Below is my current implementation: $("#one").click(function(){ v ...

Examining the integration between React, Redux, and Redux-saga through comprehensive

I'm facing a challenge with structuring integration tests for my project setup, which looks like this: app/ global/ styles/ components/ scenes/ Home/ actions.js constants.js index.jsx reducer.js sagas.js ...

Displaying a date and time beautifully in jQuery/JavaScript by providing the day of the week along with the specific time

Does anyone know of a Javascript library, preferably a jQuery plugin, that can take datetimes in any standard format (such as ISO 8601) and convert them into user-friendly strings like: Wednesday, 5:00pm Tomorrow, 9:00am Saturday, 11:00pm I'm not c ...

What might be the reason for the border not reaching the bottom of the popup in my chrome extension?

I am currently working on a Chrome extension and using Bootstrap 5 with Sass to style its popup. However, I have encountered an issue where the border of the popup does not extend to the bottom as expected. What could be causing this problem? popup.html & ...

The Angular frontend appears to be experiencing difficulties displaying content on the website

I'm currently working through the AngularJS on Rails tutorial from Thinkster(). Check out my progress so far https://jsfiddle.net/dcbavw4e/ I'm not seeing anything on the web page. I've already installed node.js and npm. Are there any othe ...

Add a new module to your project without having to rely on the initial

I'm looking to experiment with a module by making some adjustments for testing purposes. You can find the code here. Currently, all I need to do is type "npm install angular2-grid" in my terminal to add it to my project. Here's my concern: If ...

Using an AJAX request to edit a record directly without the need for a

When updating a record, I typically utilize CRUD operations and a store setup similar to the following: storeId: 'storeId', model: 'model', pageSize: 10, autoLoad: true, proxy: { typ ...

Converting Blob to File in Electron: A step-by-step guide

Is there a way to convert a Blob into a File object in ElectronJS? I attempted the following: return new File([blob], fileName, {lastModified: new Date().getTime(), type: blob.type}); However, it appears that ElectronJs handles the File object differently ...