Conceal the scrollbar and enable horizontal swiping using CSS

I have set up a container where I want the content to scroll horizontally from left to right on mobile devices, and I would like to be able to swipe to navigate while hiding the scrollbar. You can view the implementation on this JSfiddle link

Do you think using a JS plugin is necessary for this functionality or is there an easy way to achieve it? Any suggestions are welcome.

.spotlight_graphs {
  bottom: 30px;
  clear: both;
  left: 0;
  margin-left: auto;
  margin-right: auto;
  max-width: 360px;
  overflow: auto;
  position: absolute;
  right: 0;
  width: 100%;
  background-color:#cbcbcb;
  overflow:auto;
  padding:10px;
}
.spotlight_graphs > ul {
  font-size: 0;
  list-style: outside none none;
  margin: 0;
  padding: 0;
  text-align:left;
  width:200%;
}
.spotlight_graphs > ul > li {
  max-width: 90px;
  width: 33%;
  display:inline-block;
  background-color:#dec8c8;
  height:100px;
  margin:0 5px 5px 0;
  border:1px solid #333333;
}
.spotlight_graphs > ul > li > .graph_detail {
  color: #404040;
  float: left;
  font-size: 14px;
  text-align: center;
  text-transform: uppercase;
  width: 100%;
}
<div class="spotlight_graphs">
  <ul>
    <li>
      <div class="graph_detail"> This is dummy title </div>
    </li>
    <li>
      <div class="graph_detail"> This is dummy title </div>
    </li>
    <li>
      <div class="graph_detail"> This is dummy title </div>
    </li>
    <li>
      <div class="graph_detail"> This is dummy title </div>
    </li>
    <li>
      <div class="graph_detail"> This is dummy title </div>
    </li>
  </ul>
</div>

Answer №1

In case you are using a WebKit-based browser like Chrome or Safari, you can easily include the code snippet below in your CSS file. View the demo -> https://jsfiddle.net/xzc7khk0/8/

::-webkit-scrollbar { display: none; }

Answer №2

My preferred method for achieving this effect is by utilizing CSS only and simply rotating the items 90 degrees.

If you're looking for a detailed explanation, I highly recommend checking out this resource: link.

Alternatively, you can create a container div with a height less than the scrolling div and set its overflow to hidden to hide the scrollbar. Here's an example:

.hideScroll {
  height: 129px;
  overflow: hidden;
  position: relative;
}

You can view my updated version of your fiddle here: updated fiddle

Answer №3

As mentioned by @Stan George, achieving this can be done using CSS.

This particular CSS code is tailored for mobile devices, specifically to hide the scrollbar. Make sure to apply it to your scrollable div.

.spotlight_graphs::-webkit-scrollbar{
    background-color:transparent;
}

By doing this, the scrollbar will no longer be visible but you can still scroll through the content.

Answer №4

Simple to achieve using Webkit in CSS

html {
    overflow: scroll;
    overflow-x: hidden;
}
.spotlight_graphs::-webkit-scrollbar {
    width: 0px;  //eliminate scrollbar width
    background: transparent;  //if desired, hide the scrollbar
}

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

Combining td elements within a table

Currently, I am working on creating a weekly calendar using a combination of JavaScript and PHP to interact with an SQL table. The process involves generating an empty table structure in JavaScript and then populating specific cells with data retrieved fro ...

Using Jquery to eliminate the selected option from the second dropdown list after choosing from the first

Currently, I have implemented this code to enable me to choose an item from dropdown 1 and then remove the same item from dropdown 2. $("#BoxName").change(function(){ var selectedItem = $(this).val(); var nextDropdown = $(this).parent("td").nex ...

Guide on removing material-ui from your project and updating to the newest version of MUI

I need to update my React app's material-ui package to the latest version. Can someone provide instructions on how to uninstall the old version and install the new MUI? UPDATED: In my package.json file, the current dependencies are listed as: ...

What is the best way to retrieve a response from a PHP file as an array through Ajax?

Seeking assistance in retrieving a complete address by entering the postal code in an HTML form textbox and clicking a button. The setup involves two files - one containing the ajax function and the other housing the PHP code. Uncertainty looms over whethe ...

Achieving consistent text alignment in HTML and CSS without relying on tables

As I delve into the world of HTML and CSS, I've taken a traditional approach by crafting a login page complete with three input controls (two text inputs and one button). To ensure proper alignment of these elements, I initially turned to the trusty & ...

Tips for customizing the main select all checkbox in Material-UI React data grid

Utilizing a data grid with multiple selection in Material UI React, I have styled the headings with a dark background color and light text color. To maintain consistency, I also want to apply the same styling to the select all checkbox at the top. Althou ...

Is there a way to dynamically fetch and run JavaScript code from the server without resorting to the use of the

In my current project, I am developing a unique PHP framework that empowers PHP developers to effortlessly craft ExtJS interfaces containing forms, grids, tabpanels, and menus exclusively through PHP classes. To illustrate, creating a TabPanel in this fra ...

What is the importance of using a polyfill in Babel instead of automatically transpiling certain methods?

Recently, I have been diving into a course that delves into the use of babel in JavaScript. It was explained to me that babel, with the preset "env," is able to transpile newer versions of ES into ES5. However, I found myself facing a situation where the a ...

Submit data in the manner of a curl request

Instead of using a curl command to push a file to a web server, I am attempting to create a simple webpage where I can select the file and submit it. Here is the HTML and JavaScript code I have written for this purpose: <html> <body> <i ...

Steps for eliminating double quotes from the start and end of a numbered value within a list

I currently have the following data: let str = "1,2,3,4" My goal is to convert it into an array like this: arr = [1,2,3,4] ...

incorporating additional lines into the datatable with the help of jquery

I am attempting to directly add rows to the datatable by assigning values in the .js file through the Metronic theme. However, despite displaying item values during debugging, the values are not being added to the datatable row array and thus not reflect ...

Tips for ensuring compatibility of CSS in IE7 and IE8

Despite using the following styles to dynamically display alternative colors in my HTML code, I am facing compatibility issues with IE7 and IE8. Surprisingly, everything works perfectly fine on IE9 and above. It seems these styles are not supported by IE7 ...

Having difficulty uploading files to my website [PHP]

I'm having trouble with a PHP tutorial I followed for uploading an image. Despite my best efforts, the upload always fails and I can't figure out why. I've rewritten the code multiple times but the problem persists. The goal of this code is ...

HTML dropdown menu to trigger an action with the submitted URL

I need assistance creating a menu of options with corresponding URL actions. Here is the structure I have in mind: <form> <select> <option value="1">1</option> <option value="2">2</option> <option value="3 ...

Although JQuery is able to remove a row from the page, the record in the database is not

I'm having some trouble using jQuery and Ajax to delete a row on the page as well as a record in the database. The row on the page is successfully removed, but the PHP file isn't being called. I only have an echo statement in the PHP for error ch ...

Error in public build of Gatsby & Contentful site due to incorrect file paths

Encountering difficulties while attempting to deploy a Gatsby site with Contentful CMS. Development mode runs smoothly, but issues arise during the build process. Upon executing the Gatsby build command, the site is deployed successfully initially. Howeve ...

Ways to cap the height of elements at predetermined values ("stepped") depending on the content within

After posting a question on this topic here, I am seeking advice on how to implement "step-based heights" for a div element. To further clarify, my goal is to have each box with a height that is a multiple of 400px. For example, if the height is 345px, it ...

In Javascript, have an audio clip play every 30 seconds

My webpage has a unique feature - it automatically plays a short audio clip as soon as the page loads. This functionality is achieved using a special audio player called nifty player. Here is the code snippet for embedding the player: <object classid= ...

Convert an array to UTF-8 encoding and extract the values into a text input field

Having encountered a minor issue, I've successfully moved data from one file to another using Ajax with the help of echo in my query. However, I'm now attempting to utilize json_encode(); and facing some difficulties. Could someone please point o ...

Using Node.js to parse JSON data fetched from the web

My current challenge involves retrieving and parsing JSON from a web API (https://api.coinmarketcap.com/v1/ticker/?limit=3) in order to extract the name and price_usd fields. For example: [ { ... sample data provided ... } ] The code snippet I am wo ...