The stickiness of elements causes scrollbars to disappear in Chrome 77 on OSX

In this scenario, I have set up two tables where the first one has a sticky header achieved with

  position: sticky;
  top: 0px;

https://codepen.io/seunje/pen/JjjRVLm

The sticky header works perfectly fine, but there is an issue with scrollbars disappearing! This problem seems to occur only in Chrome.

Is there a workaround available for Chrome?

.container {
  height: 50px;
  overflow: auto;
}
.table {
  display: table;
  width: 100%;
}
.tr.sticky-header {
  position: sticky;
  top: 0px;
}
.td.sticky-header {
  position: sticky;
  top: 0px;
}
.tr {
  display: table-row;
}
.td {
  display: table-cell;
}
<div class="container">
  <div class="table">
    <div class="tr sticky-header">
      <div class="td sticky-header">H1</div>
      <div class="td sticky-header">H2</div>
      <div class="td sticky-header">H3</div>
      <div class="td sticky-header">H4</div>
      <div class="td sticky-header">H5</div>
    </div>
        <div class="tr">
      <div class="td">1</div>
      <div class="td">2</div>
      <div class="td">3</div>
      <div class="td">4</div>
      <div class="td">5</div>
    </div>
        <div class="tr">
      <div class="td">1</div>
      <div class="td">2</div>
      <div class="td">3</div>
      <div class="td">4</div>
      <div class="td">5</div>
    </div>
        <div class="tr">
      <div class="td">1</div>
      <div class="td">2</div>
      <div class="td">3</div>
      <div class="td">4</div>
      <div class="td">5</div>
    </div>
  </div>
</div>
<div class="container">
  <div class="table">
    <div class="tr header">
      <div class="td header">H1</div>
      <div class="td header">H2</div>
      <div class="td header">H3</div>
      <div class="td header">H4</div>
      <div class="td header">H5</div>
    </div>
        <div class="tr">
      <div class="td">1</div>
      <div class="td">2</div>
      <div class="td">3</div>
      <div class="td">4</div>
      <div class="td">5</div>
    </div>
        <div class="tr">
      <div class="td">1</div>
      <div class="td">2</div>
      <div class="td">3</div>
      <div class="td">4</div>
      <div class="td">5</div>
    </div>
        <div class="tr">
      <div class="td">1</div>
      <div class="td">2</div>
      <div class="td">3</div>
      <div class="td">4</div>
      <div class="td">5</div>
    </div>
  </div>
</div>

Answer №1

To keep the header noticeable at all times, consider adding a background color and increasing its z-index value.

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

How can we incorporate "req.getParameter" within a "for loop" to store data in the database based on the user-defined quantity provided in another servlet?

Currently, I am working on a system where teachers have the ability to edit exams they have created. However, an issue arises when trying to save the questions and answers, as it depends on the number of questions in the exam. While requesting variables f ...

Encountering a CSS syntax error within CodeSandbox when attempting to input code within brackets

Why is it that I don't see syntax errors in VSCode, but always encounter them in CodeSandbox? What could be causing this discrepancy and how can I resolve it? Any advice would be greatly appreciated. Thank you in advance. Here's an example of th ...

The hamburger menu appears to be missing when viewing in Safari, while it functions properly on both Chrome and Firefox browsers

My website has a responsive menu that functions perfectly in Chrome and Firefox, but encounters issues in Safari on mobile devices. The site is built using Elementor WordPress and I believe adding some -webkit- properties could solve the problem, but I&apo ...

utilizing tabview for component replacement

Having trouble changing components in Angular 7 with PrimeNG tabview tabs? Need some assistance? I have a setup with 3 components, and I want to switch between them when clicking on the panel inside the tabview. I've tried using onchange functions i ...

Using the jqueryRotate plugin to rotate an image by 90 degrees

Is there a way to rotate images on a webpage using the JQueryRotate script? I have 10 images that I want to be able to rotate when clicked, but I'm not sure how to implement it. Any assistance would be welcomed. This is the HTML code for the images: ...

Apply pointer style to the CSS only when a division contains text

If there is plain text inside a div with class="x95qze", how can we add cursor:pointer only to the second div that contains the text Cursor pointer required here. The div with class="x95qze" will not change. The content of the div may ...

jQuery document.ready not triggering on second screen on Android device

Why is jQuery docment.ready not firing on the second screen, but working fine on the first/initial screen? I also have jQuery Mobile included in the html. Could jQuery Mobile be causing document.ready to not work? I've heard that we should use jQuery ...

How to place a stylish font over an image and recreate hover effects

I am looking to place social media icons below an image next to the photo's title, including Facebook, Twitter, Soundcloud, and Instagram. I want these icons to rotate along with the image when it is hovered over. HTML <div class="polaroid-image ...

Absolute positioned content causing unexpected spacing on top of relative positioned content

I've been experimenting with a fantastic technique by Chris Coyier for implementing full page video backgrounds with content scrolling over the video. However, I've encountered an issue where there's an unexpected gap to the right in Windows ...

Escape from an iframe with the help of a buster

My website is being targeted by a code that prevents it from breaking out of an iframe. Despite trying different frame breaker scripts, I have not been successful in resolving this issue. Any assistance would be greatly appreciated. Thanks! Buster: func ...

The Javascript function will only initiate upon a manual reload of the page

My function is working perfectly, but only after I reload the page once it has been loaded. This function is a timer that starts counting down from 10 to 0 as soon as the page loads (which is the intended behavior). However, when I first land on the page ...

Guide to align elements (cards) side by side in a row within a container element (div)

I have a question that bears resemblance to another one found on this site. I decided to create my own version of the Material UI Card example from https://material-ui.com/demos/cards/. You can view and edit my version on the sandbox editor by clicking he ...

Flexbox divs that adapt to different screen sizes

Hello everyone, I need help with a school project where I have to make blocks responsive and change their layout based on screen width. Specifically, above 1024px they should be in 2 horizontal rows, and below 1024px in 2 vertical rows, always spelling out ...

Is it possible to run a query directly from HTML code?

I am trying to retrieve data from my table that includes two columns: Judul, Isi. <head><link type="text/css" rel="stylesheet" href="addnewpage.css"/</head> <body> <?php $k = mysqli_connect("local ...

What is preventing the Selenium WebDriver from clicking on elements, despite their presence and focus?

Once again, I am facing a Selenium issue. Last week everything was running smoothly, but today when I attempted to write some new tests, I encountered a strange problem. Every time I try to click on something, Selenium seems to ignore the click. Even wit ...

Assigning the Style property to an element using a string that includes HTML tags

My HTML string is populated with elements such as button, li, span, and more. I am looking to add specific styles to buttons based on their class name. For example, if button.btn { some styles } and button.btn-success { some other styles } O ...

Utilizing Django for tables with over two items in a template

I've been on the lookout for a solution to create a Django template that can display more than just 2 values per row in a table. Imagine having a class with 5 attributes, and wanting these attribute values showcased in a table on your HTML page. Init ...

What is the best method for applying classes to a collection of DOM elements with jQuery?

I attempted two different methods of iterating through the arrays, but encountered the same error: addClass is not function First attempt using a for loop: function game(){ var cards = $('.card'); function initialize(){ for ...

Enhancing Your Navbar Brand with Images using Flexbox and Bootstrap

I've been working on a project where I decided to customize the Bootstrap navbar by breaking it up into flexboxes in order to align everything according to the specifications. However, I've encountered an issue while trying to place a logo in the ...

Excessive content spilling over the div container

Hello everyone I've been trying to set up a div that includes an image, a title, and some text. I want the image to be aligned on the left side, with the title and text following on the right. However, I'm having an issue where the text is overf ...