The scrollbar CSS appears to be missing on iPhone browsers Chrome and Safari

After spending the entire day searching for a solution to override the irritating scrollbar issue on my iPhone, I came across this simple example:

.scroller {
  background: lightblue;
  height: 1000px;
  max-width: 400px;
  margin: 90px auto;
  padding: 40px;
}
.page {
  max-height: 90vh;
  overflow: scroll;
  background: navajowhite;
}
<div class="container">
  <div class="page">
    <div class="scroller">
      lorem ipsum
    </div>
  </div>
</div>

Despite working perfectly on web and Android Chrome, the overflow scroll functionality mysteriously does not appear on iPhone browsers like Chrome or Safari.

In a nutshell:

While tinkering with Codepen, I observed that scrollbars appeared in HTML, CSS, JS snippet boxes on my iPhone. Intrigued, I delved into how this website achieved this feat, discovering it to be a simulated scrollbar element. Though I attempted to implement this technique, the effort proved too labor-intensive and ultimately futile.

I also experimented with using -webkit-overflow-scrolling: touch;

For a closer look at the original website, visit here

Any simple ideas are welcome!

Answer №1

When supported, adjusting the ::-webkit-scrollbar style properties will keep the scrollbar visible on most devices instead of hiding them like mobile browser defaults.

With the exception of Firefox and Internet Explorer, almost all commonly used browsers support this feature.

There are various properties that can be customized:

::-webkit-scrollbar              { /* 1 */ }
::-webkit-scrollbar-button       { /* 2 */ }
::-webkit-scrollbar-track        { /* 3 */ }
::-webkit-scrollbar-track-piece  { /* 4 */ }
::-webkit-scrollbar-thumb        { /* 5 */ }
::-webkit-scrollbar-corner       { /* 6 */ }
::-webkit-resizer                { /* 7 */ }

https://i.sstatic.net/eNvy3.png

Additionally, there are numerous pseudo-class selectors which allow for precise selection of specific parts:

:horizontal
:vertical
:decrement
:increment
:start
:end 
:double-button
:single-button
:no-button
:corner-present
:window-inactive

Firefox supports CSS Scrollbars Module Level 1, but does not currently support the ::-webkit- options.

For further reference, you may find these links helpful:

Here is a simple example using minimalistic -webkit-scrollbar style rules:

.scroller {
  background: lightblue;
  height: 1000px;
  max-width: 400px;
  margin: 90px auto;
  padding: 40px;
}
.page {
  max-height: 90vh;
  overflow: scroll;
  background: navajowhite;
}
/* minimal */
.page::-webkit-scrollbar {
    width: .5em; /* applies to vertical scrollbar only */
    height: .5em; /* applies to horizontal scrollbar only */
}
.page::-webkit-scrollbar-track {
  background: #ccc;
}
.page::-webkit-scrollbar-thumb {
  background: #888;
}
.page::-webkit-scrollbar-thumb:hover {
  background: #555;
}
<div class="container">
  <div class="page">
    <div class="scroller">
      lorem ipsum
    </div>
  </div>
</div>

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

Avoid choosing the menuItem when clicking on the icon within the Material UI select component

I am trying to create a dropdown menu that allows users to delete items. However, when I click on the delete icon within a menu item, the entire menu item gets selected automatically. How can I prevent this default behavior? Here is my code: { dropd ...

Tips for transferring information from Angular 6 to Node.js

Having recently delved into Angular 6 for the first time, I find myself tasked with sending data to a Node.js server. The code snippet below illustrates my approach within an Angular function: import { Component, OnInit } from '@angular/core'; ...

Show the ajax appended html only after reaching a specific threshold

I am currently utilizing AJAX to fetch additional results from my database. Below is the basic script I am using: $('#loadmorebuilds-div').click(function() { $.ajax({ url: 'includes/loadmorebuilds.php?type=' + type + &ap ...

Using jQuery to target form elements that have a specific class assigned to them

I am facing an issue with targeting input fields within a specific form on a page. The form has a certain class, let's say "has-error," and I want to remove this class from all the input fields in that form. I attempted the following code snippet: t ...

error occurred while trying to upload a file

I am encountering an issue while trying to upload a file using PHP. Here is the HTML code snippet: <form enctype="multipart/form-data" id="form" action="action.php"> <input type="file" name="file"/><br/><br/> <input type ...

How can I center a Bootstrap modal vertically and make it responsive?

Is there a way to vertically center the bootstrap modal? I have been searching for a solution, but none seem to be responsive or effective. My website is using Bootstrap 3. The modal does not adjust properly on smaller screens or when the browser window i ...

Initiate a function following a 3-second click on an image

I'm facing a peculiar challenge with my website - I have an invisible button that needs to be pressed for 3 seconds in order to trigger a specific action. Here is what I've attempted so far: $("#basicChn").on({ mousedown: function() { $ ...

Enhancing HTML Vue JS by Dynamically Adding Rows Based on Multiple Selections

<div id="addForm"> <div class="row"> <div class="col-md-4"> <div class="form-group label-floating"> <label class="control-label">Case Type</label> <select class="form-control" v-mo ...

"Is there a way to modify the color of the button once it's been clicked, but only for the specific button that was

Looking to create a Quiz App using React and facing an issue where all buttons change color when clicked, instead of just the one that was clicked. Any solutions on how to make only the clicked button change its color in React.js? App.js import Main from ...

Creating a custom JavaScript clock based on stored database values

I am looking to create an analog clock using JavaScript. I have both working hours and off hours stored in a database. My goal is to display working hours in one color and off hours in another color on the clock. How can I achieve this? The database prov ...

What is the reason .navbar-dark is not functioning in Bootstrap v5.2?

I am puzzled by the fact that navbar-dark is not changing the text color in the nav. I'm not sure why this is happening. Any insights would be greatly appreciated! <!doctype html> <html lang="en"> <head> <meta charset=" ...

How to access a variable from within a Phonegap DB function and return it outside of the

I'm struggling with a phonegap db JavaScript script that isn't returning the final string variable "feeds" outside the function. It's currently showing as "undefined". I need help making the necessary changes to properly return the "feeds" v ...

The image fails to display correctly

As I work on creating a basic webpage in HTML and JavaScript, my goal is to validate certain parameters (such as width, height) of an image that users upload via a form. In JavaScript, I extract the file from the form and attempt to display it as an image ...

Title slide on quarto featuring a captivating full coverage background image with a sleek row of icons at the bottom

I am currently working on creating a title slide for a reveal.js presentation in Rstudio using quarto. My goal is to have a background image covering the entire slide and include one or more small icons at the bottom (specifically on this slide only). I ha ...

Using PHP to store cookies

<?php $_SESSION['name'] = array($_POST['name']) ; $n = $_SESSION['name'][0]; setcookie('name[0]',$n,time()+(60*30)); ?> <html> <form class="contact100-form validate-form" action="step-3.php" > ...

Creating a tool to display mouse coordinates as a pointer on an HTML5 canvas

I'm struggling with mouse coordinates while working on canvas in HTML5. My approach involves using JavaScript for drawing on the canvas. Below is my current code to track the mouse pointer within the canvas: $('#canvasID').mousedown(functi ...

Exploring creative methods for incorporating images in checkboxes with CSS or potentially JavaScript

Although it may seem like a basic question, I have never encountered this particular task before. My designer is requesting something similar to this design for checkboxes (positioned on the left side with grey for checked boxes and white for unchecked). ...

Angular Dynamic Alert Service

Is it possible to customize the text in an Angular Alert service dynamically? I'm looking to make certain words bold, add new lines, and center specific parts of the text. Specifically, I want the word "success" to be bold and centered, while the rest ...

html The "download" attribute causing a new tab to open rather than initiating a

I have a website built with Angular 4, where users can download images from an Amazon S3 bucket. However, I encountered an issue wherein instead of downloading the image, it opens in a new tab. I've tested this problem on different browsers such as Fi ...

I'm curious as to why the web browser is showing a timestamp below the image I have on my HTML page

Issue at Hand: I am currently working on coding a website that involves displaying an image. However, when the image is loaded, a timestamp appears underneath it in the web browser. Query: Could you please shed some light on why a timestamp is showing up ...