When a table has overflow set to auto, any content that exceeds its dimensions will

The issue at hand is explained in the fiddle provided. The problem arises when there is a scrollable table with a context menu inside it, and with the overflow-x: auto property set, the visibility of this "context menu" is hindered.

table {
  overflow: auto;
  width: 100%;
  display: block;
}

.absoluteElement {
  position: absolute;
}
<h2>ABSOLUTE Position Problem</h2>
<table>
  <thead>
    <tr>
      <th>Column 1</th>
      <th>Column 2</th>
      <th>Column 3</th>
      <th>Column 4</th>
      <th>Column 5</th>
      <th>Column 6</th>
      <th>Column 7</th>
      <th>Column 8</th>
      <th>Column 9</th>
      <th>Column 10</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="position: absolute">
        <div class="absoluteElement">
          Content will scroll with the bar
        </div>
      </td>
      <td>1</td>
      <td>2</td>
      <td>3</td>
      <td>4</td>
      <td>5</td>
      <td>6</td>
      <td>7</td>
      <td>8</td>
      <td>9</td>
    </tr>
  </tbody>
</table>

https://jsfiddle.net/ohwy3z6L/16/

Is there a way to enable scrolling on the table without compromising the visibility of the context menu?

Answer №1

It seems like there may be some confusion with your question, but I'll do my best to address it. Please let me know if anything is incorrect so I can make the necessary adjustments.

tr {
  overflow: auto;
  width: 100%;
}

.relativeElement {
  position: relative;
  /* Insert a dropdown/context menu on the grid here */
  top: 10px;
  left: 15px;
}

.absoluteElement {
  position: absolute;
  /* Insert a dropdown/context menu on the grid here */
  top: 10px;
  left: 15px;
}
<h2>RELATIVE Position Issue</h2>
<table>
  <thead>
    <tr>
      <th>Column 1</th>
      <th>Column 2</th>
      <th>Column 3</th>
      <th>Column 4</th>
      <th>Column 5</th>
      <th>Column 6</th>
      <th>Column 7</th>
      <th>Column 8</th>
      <th>Column 9</th>
      <th>Column 10</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>
        <div class="relativeElement">
          Content will be truncated at this point
        </div>
      </td>
      <td>1</td>
      <td>2</td>
      <td>3</td>
      <td>4</td>
      <td>5</td>
      <td>6</td>
      <td>7</td>
      <td>8</td>
      <td>9</td>
    </tr>
  </tbody>
</table>

<h2>ABSOLUTE Position Issue</h2>
<table>
  <thead>
    <tr>
      <th>Column 1</th>
      <th>Column 2</th>
      <th>Column 3</th>
      <th>Column 4</th>
      <th>Column 5</th>
      <th>Column 6</th>
      <th>Column 7</th>
      <th>Column 8</th>
      <th>Column 9</th>
      <th>Column 10</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="position: relative">
        <div class="absoluteElement">
          Content will move along with the scrollbar
        </div>
      </td>
      <td>1</td>
      <td>2</td>
      <td>3</td>
      <td>4</td>
      <td>5</td>
      <td>6</td>
      <td>7</td>
      <td>8</td>
      <td>9</td>
    </tr>
  </tbody>
</table>

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

What is the best way to trigger the selection options in a dropdown menu with several buttons?

Is it possible to display the options from a select-option tag using a different button? I have either a div or another button. I want to be able to show the list of options from my select tag by clicking this button. Here is my select tag: <select&g ...

The use of non-breaking space symbol ( ) does not function properly in Weblogic 14

After upgrading from Weblogic 12 to Weblogic 14 Server, I encountered a change in behavior. Previous Status Everything was functioning properly before the update. When requesting an html page with &nbsp; whitespaces, the server would include these spa ...

Accessing JSON data through crawling may trigger an "Invalid access" warning

Currently extracting data, I came across this base URL After inspecting chrome's developer tools - Network tab, I found the following URL: international?Adt=1&Chd=0&ECITY1=HKG&ECITY2=ICN&Fa…019.03.13.&TRIP=RT&W ...

Issue with customizing Bootstrap5 table colors based on themes

In my latest project, I decided to customize Bootstrap 5.1.3 using Sass in order to introduce some new color themes to the panels. I quickly realized that customizing Bootstrap 5.1.3 is not as straightforward as it was with Bootstrap 4. After updating my ...

What is causing my server to mysteriously alter the style of index.html?

After setting up a node, express, react app, I realized that when express serves static content like my CSS file, the source of the index.html shows an additional style tag in the head section: <style type="text/css">* {}</style> I confirme ...

Issue with styled-components not being exported

Issue: ./src/card.js There was an import error: 'Bottom' is not exported from './styles/cards.style'. card.js import React from 'react' import { Bottom, Color, Text, Image } from "./styles/cards.style"; fu ...

In a React application, adjusting the main container height to 100vh results in the window.scrollY position being set to

I was facing problems with flashing on the Safari/Firefox browsers. By setting the main container height to max-height: 100vh, I managed to resolve the flickering issue. However, I am also looking for a solution to keep track of the window.scrollY positi ...

Apache causes HTML download tag to malfunction

I have an HTML file that includes the following code: <a href="/Library/WebServer/Documents/file.zip" download="file.zip"> Download here </a> When I test this HTML page on Chrome, it successfully allows me to download the file. However, when ...

Retrieving specific values for each key in JSON using PHP

Looking for a solution with PHP to extract specific information from JSON files based on set criteria. Here is an example of part of the JSON data: "Main": [{ "count": 7, "coordinates": [89,77], "description": "Office", },{ "count": 8, ...

Creating a persistent gap BETWEEN li inline list items

I'm seeking a solution to create horizontal links using a list. I know that I need to apply the display: block property to the ul element and set display: inline for the li items. While there are several inquiries about maintaining a consistent width ...

What is the best way to eliminate an unassigned margin from my layout?

The content of my css file is as follows: .menu { background-color: black; color: white; height: 100px; opacity: 0.5; } html { background-image: url('image.jpg'); background-size:cover; } Despite the lack of text ...

Mediawiki needs to be able to respond effectively to constantly changing and evolving content

My extension generates content dynamically for certain pages. For example, I create headlines using <html> <h1>, <h2> and <h3> tags. I want my mediawiki to respond to these headlines and generate a directory dynamically. I attempte ...

Is there a way to prevent certain words or letters from being exchanged in PHP?

In my PHP project, I am trying to replace text in one textarea and display it in another. While most of the code works fine, there are some parts that are causing issues. Currently, I am using the str_ireplace function with around 60 different words and m ...

Remove the presence of a black square when selecting elements using CSS

Update: After some investigation, I discovered that the mysterious black square is actually a part of the scroll bar. By adding the following code snippet: select::-webkit-scrollbar { display: none; } The square no longer appears. Initially, my se ...

What is the best way to incorporate CSS styles into a PHP loop?

Struggling to implement CSS styles on a PHP loop: <h3 class='title'></h3> The CSS style doesn't seem to be taking effect: .title{ color : red; } I attempted surrounding the echo with <?php ?> tags and then applying ...

Magento theme installation on the website encountered unexpected obstacles

Hi everyone, I'm currently in the process of constructing a website with Magento. However, I've encountered some issues after trying to install a theme. It seems like certain files, including CSS, are not loading properly. To provide better conte ...

Save property using the useState hook

I am working on implementing a sorting function in the child component, where the props are passed in from the parent through an axios call. Should I: Store the prop in the child component's useState? Pass the parent's setState function as a pro ...

Is there a way to restrict the number of checkboxes selected based on the values of radio buttons?

I am currently working with a group of radio buttons: <input type="radio" name="attending_days" value="06-18-13"/>Tuesday June 18, 2013 <input type="radio" name="attending_days" value="06-18-13"/>Wednesday June 19, 2013 <input type="radio" ...

How can I achieve a transparent background for a radio button in Chrome?

Today, I spent some time experimenting with the radio button to see if I could make its background transparent. I attempted the following CSS styling: input[type=radio] { background-color:transparent; background-image:none; -webkit-backface-v ...

Is there a way to retrieve a list of li tags using BeautifulSoup4 in Python?

I am attempting to extract information from a Persian webpage where I need to retrieve only 3 li tags out of a ul element that contains 6 of them. The issue is that each li tag also has nested li tags within it, so when I use soup.find_all('li'), ...