What is the best method for concealing the scrollbar in HTML?

Is there a way to hide the scrollbar while still allowing scrolling functionality? I've tried using overflow: hidden but it prevents me from scrolling to see the content.

How can I achieve this using HTML/CSS/JavaScript?

I attempted to style the scrollbar with no luck, so I created a custom scrollbar using divs and jQuery. However, now I have two scrollbars - one custom and one default. How do I hide the default scrollbar?

I want to avoid using -webkit- due to browser compatibility issues.

I am trying to hide the scrollbar in the code below:

.container{
  width: 100%;
  background-color: #d5d5d5;
}
.sidebarcontainer{
  width: 300PX;
  height: 6000px;
  display: inline-block;
  box-sizing: border-box;
  padding: 5px;
  padding-right: 2px;
}
.innersidebarcontainer{
  position: relative;
      width: 100%;
    height: 100%;
}
.sidebar{
  width: 300px;
  background-color: teal;
  height: 2000px;
  top: 1px;
  position: absolute;
}
.mainpage{
  width: calc(100% - 300px);
  padding: 5px;
  padding-right: 2px;
  height: 6000px;
  display: inline-block;
  box-sizing: border-box;
}
.page{
  width: 100%;
  height: 100%;
  background-color: white;
}
.footer{
  height: 500px;
  width: 100%;
  margin: 0 auto;
  background-color: purple
}
<body>
  <div class="container">
    <div class="sidebarcontainer">
      <div class="innersidebarcontainer">
        <div class="sidebar">
        </div>
      </div>
    </div>
    <div class="mainpage">
      <div class="page"></div>
    </div> 
  </div>
  <div class="footer"></div>
</body>

If you have any solutions, please share!

Answer №1

Is using overflow:auto; completely ruled out?

The content remains hidden until it is required to be displayed.

Answer №2

To achieve the desired outcome, make sure to include the following CSS styles:

#container {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

#content {
    width: 100%;
    height: 100%;
    overflow-y: scroll;
    padding-right: 17px;
}

Feel free to check out the demonstration on this fiddle link: http://jsfiddle.net/5GCsJ/954/

Answer №3

To create a transparent scroll bar, you can use the code below:


    ::-webkit-scrollbar
    {
        width:0px;
    }
    ::-webkit-scrollbar-track-piece
    {
        background-color: transparent;
    }

I trust this solution will be beneficial for your needs!

Answer №4

Here is a suggestion:

yourDiv::-webkit-scrollbar{
    width: 0px;
}

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

A pop-up modal that remains closed thanks to sessionStorage

I've been working on creating a modal that pops up after a short delay, but once closed, it shouldn't appear again unless the user closes the website and starts a new session. While I have successfully designed the modal, integrating sessionStora ...

Command handler for a Discord.js Music Bot

Currently facing challenges while trying to integrate a music bot into my command handler. This is the snippet of code I am using: delete require.cache[require.resolve(`./commands/${command}.js`)]; let commandFile = require(`./commands/${command}.js`) ...

Is it impossible to send an array of objects as a parameter to a function?

My goal is to pass the selected values from a dropdown menu to a function called handleSearch(), and then have them passed to another function named filterList(). Unfortunately, I'm encountering an issue where the values do not seem to reach the filt ...

Having issues with inline conditional statements in Angular 5

There is a minor issue that I've been struggling to understand... so In my code, I have an inline if statement like this: <button *ngIf="item?.fields?.assetType !== 'tool' || item?.fields?.assetType !== 'questions'">NEXT< ...

Guide on how to show an icon in Meteor when a link is clicked

Is there a way to display a viewed icon upon clicking a link in Meteor? On my list of jobs page, when a user clicks on a job, they are taken to the description page. I would like to add an icon to the post indicating that the user has viewed it. ...

Creating an interactive dropdown feature using AngularJS or Ionic framework

$scope.AllCities = window.localStorage.getItem['all_cities']; <div class="row"> <div class="col"> <div class="select-child" ng-options="citie.name for citie in AllCities" ng-model="data.city"> <label&g ...

Verifying username using an Ajax call

Currently, I am working on developing a signup form using HTML/CSS/JS that involves utilizing an AJAX request to interact with the server. Within my jQuery code, I have implemented a method for validating the form inputs, which also triggers a function (en ...

Troubleshooting: Issue with dynamically updating innerHTML of element using AJAX in response to selection input change event

I'm facing a challenge in retrieving the value of a product from a database based on user selection in a <select> element and displaying this value using AJAX in another element. When I directly access precio.php?q=PRODUCTO%201, it returns the d ...

Ways to retrieve the selected option from a dropdown list

How can I extract the option value from a dynamically populated Select button in order to retrieve the necessary data from my database? I am unsure of how to obtain the value stored in the $giftName variable. I have attempted to use both jQuery and JavaS ...

Setting up WebPack for TypeScript with import functionality

A tutorial on webpack configuration for typescript typically demonstrates the following: const path = require('path'); module.exports = { ... } Is it more advantageous to utilize ES modules and configure it with import statements instead? Or is ...

RequestDispatcher.forward() does not work when servlet is invoked through an Ajax POST request

My login page involves user authentication through the firebase and sending the request to a servlet. When I click the submit button with correct credentials, the firebase authentication works, the servlet is called but an error is displayed in the browser ...

Tips for limiting access to certain views in an AngularJS application

I need to restrict users from accessing the /dashboard view and /add-item view, as well as any other views in my AngularJS application. Here is my router configuration: app.config(function($stateProvider, $urlRouterProvider){ $urlRouterProvider. ...

Having trouble placing the flash element above the HTML?

Despite my efforts to use SWFObject to embed a swf file on my webpage, it seems that the flash movie is covering some of the HTML components. Strangely enough, the HTML elements are bleeding through and appearing on top of the flash content. I've tri ...

Angular method for displaying and hiding div elements in a tab-like fashion, but without actually using tabs

I'm attempting to create tab-like functionality using divs with dynamically generated IDs through ng-repeat. <div class="col-md-10"> <div id="div{{$index}}" class="targetDiv" ng-show="setSomething" ng-repeat="question in Questions"> ...

Using CSS styling to dictate how browsers display web content, specifically through setting font size measurements in EM

On different mobile devices and various browsers such as Internet Explorer and Mozilla, the font size in some divs does not appear consistent. Specifically, on a Samsung Galaxy S6. I am using EM units: I know it may not be ideal but I prefer this method a ...

Delineating the exact widths of columns without the need for additional wrapping columns

Below is the HTML / CSS code for a Bootstrap navbar. Take a look at the screenshot to see how I want it to appear. I want the navigation bar to align with the left side of #three and be the same width as it. I'm trying to avoid putting it inside a c ...

Highlighting the navbar in the right-hand section

I need help with highlighting the navbar item that corresponds to a specific section when clicked or scrolled into view. I've tried using CSS properties and Bootstrap, but I can't seem to get it working. Any assistance would be greatly appreciate ...

Choose and adjust the size of images with a specific aspect ratio using jQuery

As I work on my Tumblr blog, I am experimenting with using jQuery to target photo entries (imgs) based on specific aspect ratios and resizing them accordingly. To be more precise: If an image's width exceeds 250px, it should be resized so that the h ...

Customize the appearance of all QProgressBars using Qt stylesheets in your C++ program

Struggling to figure out how to dynamically apply a stylesheet to multiple or all widgets in Qt Creator 4.1 (Qt 5.7) using C++. For instance, if I have 3 progress bar widgets, currently I am setting the same stylesheet for each one individually with CSS: ...

Having difficulty installing npm on Mac m1 with Monterey operating system

npm install npm ERR! code ENOENT npm ERR! syscall open npm ERR! path /Users/ahmed/package.json npm ERR! errno -2 npm ERR! enoent ENOENT: no such file or directory, open '/Users/ahmed/package.json' npm ERR! enoent This issue is likely due to npm n ...